回复 楼主 q2634303514
刚好学到这,我只在这个网站运行过,应该是可以的。
#include <stdio.h>
#include<stdlib.h>
int main() {
int magic;
int guess;
int count=0;
char order='s';
magic=rand()%1000+1;
/*printf("magic=%dn",magic);
printf("order=%cn",order);*/
do{
printf("猜数请输入s,终止请输入cn");
scanf(" %c",&order);//%c前的空格不可以删
printf("您输入了:%cn",order);
if(order=='s'){
printf("猜数范围为[1,1000]ninput:");
scanf("%d",&guess);
printf("%dn",guess);
count++;
if(guess==magic){
printf("bingo!nmagic=%dn一共猜数%d次",magic,count);
order='c';
}
else if(guess>magic){
printf("too big!n");
}
else{
printf("too small!n");
}
}
else{
printf("game over!");
}
}while(order=='s');
return 0;
}