猜数字小游戏
答案:2 悬赏:0 手机版
解决时间 2021-03-20 05:34
- 提问者网友:焚苦与心
- 2021-03-19 19:05
猜数字小游戏
最佳答案
- 五星知识达人网友:山有枢
- 2021-03-19 20:08
{
int Number = 2;
srand((unsigned)time(NULL));
int magic;
int guess;
int counter;
magic=rand()%100+1;
counter=0;
do{
printf("please guesss a magic number(0到100之间):");
scanf("%d",&guess);
counter++;
if (guess>magic)
printf("wrong!too high!你怎么这么苯,猪脑啊\n");
else if(guess printf("wrong!too low!我对你失去信心了\n");
if(counter>=Number)break;
}
while(guess!=magic);
if (counter>=Number) printf("失败!超过最多猜题次数了!\n");
else
{
printf("right!终于猜对了\n");
printf("\t* *\n");
printf("\t *\n");
printf("counter=%d\n",counter);
}
}
int Number = 2;
srand((unsigned)time(NULL));
int magic;
int guess;
int counter;
magic=rand()%100+1;
counter=0;
do{
printf("please guesss a magic number(0到100之间):");
scanf("%d",&guess);
counter++;
if (guess>magic)
printf("wrong!too high!你怎么这么苯,猪脑啊\n");
else if(guess
if(counter>=Number)break;
}
while(guess!=magic);
if (counter>=Number) printf("失败!超过最多猜题次数了!\n");
else
{
printf("right!终于猜对了\n");
printf("\t* *\n");
printf("\t *\n");
printf("counter=%d\n",counter);
}
}
全部回答
- 1楼网友:迷人又混蛋
- 2021-03-19 20:20
用for循环啊!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯