已经改正,如下:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
void circle(int i)
{
int n ;
printf("请输入您所猜的数字(0-100) n");
scanf("%d",&n);
if(i<n)
{
printf("the number is larger,input agine.n");
circle(i);
}
if(i>n)
{
printf("the number is smaller.input agine n");
circle(i);
}
if(i==n)//?不是
printf("the number is %d so congratulations!you got it!",i);
}
int main()
{
int flag =1;
printf("This is a small game,what you should do is just guess a intange number.n");
printf("Now,please guess the number!n");
srand((unsigned)time(NULL));
while(flag)
{
int i=rand()%100;//?使用 % 而不是 / ,产生的数字在0-100之间,放在循环体内,每次循环都产生一个随机数
circle(i);
printf("n继续玩请输入 1,退出请输入 0");
scanf("%d",&flag);
}
getchar();
return 0;
}
免责声明:本平台仅供信息发布交流之途,请谨慎判断信息真伪。如遇虚假诈骗信息,请立即举报
举报