Question: 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:

Write a C++ program that generates random words from a training set..

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!