网友您好, 请在下方输入框内输入要搜索的题目:
#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); }}
参考答案