#include #include const int MAX_STRING_SIZE = 20; typedef char StringType[MAX_STRING_SIZE]; const int MAX_ARRAY_SIZE = 10; const int MAX_NUM_SENTENCES = 20; void Load(StringType words[], int& size) { // size is the number of words loaded (not the index of the last word) size=0; do cin.getline(words[size],MAX_STRING_SIZE); while (words[size][0] != '\0' && (size+=1) < MAX_ARRAY_SIZE); // Post-condition: last string entered is null or size=MAX_ARRAY_SIZE } int main(void) { StringType determiners[MAX_ARRAY_SIZE], adjectives[MAX_ARRAY_SIZE], nouns[MAX_ARRAY_SIZE], verbs[MAX_ARRAY_SIZE]; int detSize, adjSize, nounSize, verbSize, i; cout << "Please enter the determiners" << endl; Load(determiners,detSize); cout << "Please enter the adjectives" << endl; Load(adjectives,adjSize); cout << "Please enter the nouns" << endl; Load(nouns,nounSize); cout << "Please enter the verbs" << endl; Load(verbs,verbSize); randomize(); for (i = 0; i < MAX_NUM_SENTENCES; i++) cout << determiners[random(detSize)] << ' ' << adjectives[random(adjSize)] << ' ' << nouns[random(nounSize)] << ' ' << verbs[random(verbSize)] << ' ' << determiners[random(detSize)] << ' ' << adjectives[random(adjSize)] << ' ' << nouns[random(nounSize)] << endl; return 0; }