1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <ctype.h>
void firstword( char *article[5], char *sentence[6]);
void secondword(char *noun[5], char *sentence[6]);
void thirdword(char *verb[5], char *sentence[6]);
void fourthword( char *preposition[5], char *sentence[6]);
void fifthword( char *article[5], char *sentence[6]);
void sixthword(char *noun[5], char *sentence[6]);
int main()
{
char *article[5]= {"the", "a", "one", "some", "any"};
char *noun[5] = { "boy", "girl", "dog", "town", "car"};
char *verb[5]= {"drove", "jumped", "ran", "walked", "skipped"};
char *preposition [5] ={ "to", "from", "over", "under", "on"};
char *sentence [6];
srand(time(0));
firstword( article,sentence);
secondword(noun, sentence);
thirdword(verb, sentence);
fourthword(preposition, sentence);
fifthword(article, sentence);
sixthword(noun, sentence);
printf("\n");
return 0;
}
void firstword( char *article[5], char *sentence[6])
{
char word1;
word1 = rand() % 5;
sentence[0] = article[word1] ;
sentence[0] = toupper(sentence[0]);
printf("%s ", sentence[0]);
}
void secondword(char *noun[5], char *sentence[6])
{
char word1;
word1 = rand() % 5;
sentence[1] = noun[word1] ;
printf("%s ", sentence[1]);
}
void thirdword(char *verb[5], char *sentence[6])
{
char word1;
word1 = rand() % 5;
sentence[2] = verb[word1] ;
printf("%s ", sentence[2]);
}
void fourthword( char *preposition[5], char *sentence[6])
{
char word1;
word1 = rand() % 5;
sentence[3] = preposition[word1] ;
printf("%s ", sentence[3]);
}
void fifthword( char *article[5], char *sentence[6])
{
char word1;
word1 = rand() % 5;
sentence[4] = article[word1] ;
printf("%s ", sentence[4]);
}
void sixthword(char *noun[5], char *sentence[6])
{
char word1;
word1 = rand() % 5;
sentence[5] = noun[word1] ;
printf("%s ", sentence[5]);
}
|