Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that generates random words from a training set.. Do not hard-code the training set! Read it from a file. A suggested

Write a C++ program that generates random words from a training set.. Do not hard-code the training set! Read it from a file. A suggested format for the input file is:

image text in transcribed

Prompt the user for the name of the input file and the number of iterations (this program will run forever without this limit!). Either prompt the user for the name of the output file, or inform the user of the name before exiting.

6 a em rst eat mate meet rate seat stream tame team tear Here are some suggestions for constants, array declarations, and helper functions (note that use of global variables will be heavily penalized) #include #include #include-cstalb> #include-ctime> #include using namespace std; const int SIZE27; // 26 chars + 1 const int WORDSIZE25; // max word size Il read from input file char cArray[SIZE]; // array of characters in set char tArray[SIZE][SIZE]; // training array //constructed by your program int firstChars [SIZE]; // array of first character multiplicities int transArray[SIZE][SIZE]; // transition array of multiplicities char word[WORDSIZE]; // word being built // helper functions int getRandom (int); I/ get next random integer int getlndex(char [SIZE], char); II get index of char in cArray char getChar(char [SIZE], int); II get char at index in cArray Be sure to seed the random number generator with the current time before using the randQ) function: srand(tim e(NULL));Il seed random number generator 6 a em rst eat mate meet rate seat stream tame team tear Here are some suggestions for constants, array declarations, and helper functions (note that use of global variables will be heavily penalized) #include #include #include-cstalb> #include-ctime> #include using namespace std; const int SIZE27; // 26 chars + 1 const int WORDSIZE25; // max word size Il read from input file char cArray[SIZE]; // array of characters in set char tArray[SIZE][SIZE]; // training array //constructed by your program int firstChars [SIZE]; // array of first character multiplicities int transArray[SIZE][SIZE]; // transition array of multiplicities char word[WORDSIZE]; // word being built // helper functions int getRandom (int); I/ get next random integer int getlndex(char [SIZE], char); II get index of char in cArray char getChar(char [SIZE], int); II get char at index in cArray Be sure to seed the random number generator with the current time before using the randQ) function: srand(tim e(NULL));Il seed random number generator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago