33,311
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
int main()
{
int result=rand()%101; //随机赋值
int guess;
char ch;
printf("please input number between 1 and 100:");
while(1)
{
scanf("%d",&guess);
getchar();
if(guess > result) //猜的数字大了
{
printf("You guess number is too big.\n");
printf("please input number between 1 and 100:");
}
if(guess < result) //猜的数字小了
{
printf("You guess number is too small\n");
printf("please input number between 1 and 100:");
}
if(guess == result) // 正确
{
printf("Bingo!\n");
printf("Do you want to quit? Y/N.\n");
scanf("%c",&ch);
if(ch == 'Y')
break;
else if(ch=='N')
printf("please input number between 1 and 100:");
continue;
}
}
}