标题:猜数游戏怎么老是high
只看楼主
a58966279
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-6
结帖率:0
 问题点数:0 回复次数:1 
猜数游戏怎么老是high
#include<stdlib.h>
#include<stdio.h>
void main()
{
    int magic;
    int guess;
    int counter;
    guess=magic-1;
    counter=0;
    while(magic!=guess)
    {
        printf("guess the magic number:");
        scanf("%d",&guess);
        counter++;
        if(guess>magic)
            printf("wrong to high\n");
        else if(guess<magic)
            printf("wrong to low\n");
    }
    printf("right\n");
    printf("guess is %d\n",counter);
}
搜索更多相关主题的帖子: counter include number wrong guess 
2017-06-07 10:48
a58966279
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2017-6-6
得分:0 
漏了magic=rand();找到错了
2017-06-07 10:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-477714-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014097 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved