[主观题]

各位大神求救。。。c语言玩猜数字游戏,单一局结束时,为什么不可以循环?下面代码:

#include<stdio.h>#include<time.h>#include<stdlib.h>void main(){ int a,b,c,num; char r; printf("welcom to guess number game,in this game you will have 10 chances to guess the right number./n"); srand((unsigned) time(NULL)); num=rand()%100+1; printf("do you want to play this game? y/n :"); scanf("%c",&r); while(r=='y') { printf("start!!/n"); printf("please input a number between 1 and 100"); scanf("%d",&a); while(a!=num) { if(a>num) { printf("bigger,input once again:"); scanf("%d",&a); } if(a<num) { printf("smaller,input once again:"); scanf("%d",&a); } } printf("you are so clever,do you want to play once more? y/n :"); scanf("%c",&r); }}

参考答案与解析:

相关试题

各位大神求救。。。c语言玩猜数字游戏,单一局结束时,为什么不可以循环?下面代码: