网友您好, 请在下方输入框内输入要搜索的题目:
#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语言玩猜数字游戏,单一局结束时,为什么不可以循环?下面代码: #includestdio.h#includetime.h#includestdlib.hvoid 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", while(r=='y') { printf("start!!\n"); printf("please input a number between 1 and 100"); scanf("%d", while(a!=num) { if(anum) { printf("bigger,input once again:"); scanf("%d", } if(anum) { printf("smaller,input once again:"); scanf("%d", } } printf("you are so clever,do you want to play once more? y/n :"); scanf("%c", }} ” 相关考题
![瑞牛题库 章节练习 历年真题 模拟试卷](http://assets.51tk.com/51_sidebar_right_index.jpg)