自娱自乐~
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(0));
int number = rand()%100 +1;
int guess;
int count = 0;
printf("我已经想好那个数了,你开始猜吧!");
do{
scanf("%d", &guess);
count ++;
if(guess>0 && guess < 100){
if(guess > number){
printf("你猜大了哟!继续猜吧~~");
}else{printf("你猜小了哟!继续猜吧~~");
}
}else{
printf("看来你不想玩了,那再见吧!\n");
goto end;
}
}while(guess != number);
printf("\n恭喜你,%d次就猜对了耶~!\n", count);
end:
return 0;
}
试着加了个退出游戏的玩法。居然成功了。耶~