//1.不要用goto语句
//2.为什么要用float ?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand((unsigned)time(NULL));
int s,n;
s=rand()%101;
while(1)
{
system("cls");
printf(" 1. play\n");
printf(" 0. exit\n");
printf("\n请输入0或1:");
fflush(stdin);
scanf("%d",&n);
if(n!=1 && n!=0)
{
printf("\n输入错误!只能输入0和1, 按任意键继续...\n");
fflush(stdin);
getchar();
continue;
}
if(n==0)
{
printf("\ngoodbye!");
return 0;
}
while(1)
{
printf("\n请输入你猜的码:");
fflush(stdin);
scanf("%d",&n);
if(n==s)
{
printf("\nBingo!");
getchar();
return 0;
}
else if(n>s)
{
printf("\n再小点!\n");
}
else if(n<s)
{
printf("\n再大点!\n");
}
}
}
return 0;
}
温馨提示:答案为网友推荐,仅供参考