70,030
社区成员




#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
int main()
{
char * article[]={"the","a","one","some","any"};
char * noun[]={"boy","girl","dog","town","car"};
char * verb[]={"drove","jumped","ran","walked","skipped"};
char * preposition[]={"to","from","over","under","on"};
char * sentence = NULL;
int i = 0;
int lenth = 100 * sizeof(char);
sentence = (char *)malloc(lenth);
printf("%d\n",lenth);
memset(sentence,'0', lenth);
srand(time(NULL));
while(i++ < 20)
{
strcpy(sentence, article[rand()%5]);
sentence=strcat(sentence," ");
sentence=strcat(sentence,noun[rand()%5]);
sentence=strcat(sentence," ");
sentence=strcat(sentence,verb[rand()%5]);
sentence=strcat(sentence," ");
sentence=strcat(sentence,preposition[rand()%5]);
sentence=strcat(sentence," ");
sentence=strcat(sentence,article[rand()%5]);
sentence=strcat(sentence," ");
sentence=strcat(sentence,noun[rand()%5]);
printf("%d = %s\n",i, sentence);
}
free(sentence);
return 0;
}