#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main(){
srand(time(0));
int a = rand();
int t;
t=a%100;
int x,count;
count=0;
printf("我想好了一个数,游戏开始,请输入数");
do{
scanf("%d",&x);
count++;
if (x>t){
printf("你猜大了");
} else if (x<t){
printf("你猜小了");
}
} while(a!=t);
printf("你用了%d次就猜对了答案",count);
}
while (a != t);
改为
while (x != t);
x 是用户输入的数字。
x是猜的数,a是最开始随机生成的数,改成while (x != t)
感谢 自学的 大意了