
供参考:
#include<stdio.h>
int main()
{
int i,cnt=0;
char ch;
while(1){
printf("吃饭吗?(y,n):");
fflush(stdout);rewind(stdin);
ch = getchar();
if(ch == 'n' || ch == 'N') break;
else cnt++;
}
switch(cnt){
case 0: case 1: case 2: case 3: case 4:
case 5:printf("小孩胃口不好,要看医生了。\n");break;
case 6: case 7: case 8: case 9:
case 10:printf("小孩胃口不错。\n");break;
default:printf("小孩太能吃了,得节食了。\n");break;
}
return 0;
}