字符串的对比和输入
先确定一个单词"chinese book",再printf"语文",然后等待输入.最后对比,对了printf"OK" 错了,printf"NO",循环,直到对为止.这个程序该如何编.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
while(1)
{
char input[100];
char input2[100];
printf("\n");
printf("Please translate the following words!!\n");
printf("\n");
printf("The word is '语文'\n");
printf("\n");
scanf("%s",input);
getchar();
if (strcmp(input,"chinesebook")==0)
{
printf("\n");
printf("Congratulations! The result is right!\n\n");
break;
}
else
printf("\n");
printf("Sorry! The result is wrong!\n\n");
printf("GO ON!\n\n");
}
system("pause");
}
[[it] 本帖最后由 小小熊宝宝 于 2008-9-18 12:26 编辑 [/it]]