标题:为什么编好的程序一执行就停止工作?求解惑
只看楼主
墨落成白
Rank: 1
等 级:新手上路
帖 子:46
专家分:4
注 册:2014-3-16
结帖率:70%
 问题点数:0 回复次数:2 
为什么编好的程序一执行就停止工作?求解惑
# include <stdio.h>
int main()
{
    int n, u, i, m;
    printf("=== This is a Number Guess Game ===\n");
    printf("Please input a Password:\n");scanf("%d",&u);   
    if(u != 765){for(i=3; i>1; )
    {
        --i;printf("This Password is wrong, you just have %d times to input again\n", i);
        scanf("%d",&u);
    }
    return 0;
    }else
    {
    do{printf("please input a number between 1 to 100 !:\n");
    scanf("%d",m);printf("Your input number is %d\n", m);}while(m>=1 && m<=100);
    if(m>=50 && m<60)printf("Sorry,Only a little smaller! Press any key to try again!\n");
    else if(m>60 && m<=70)
        printf("Sorry,Only a little bigger! Press any key to try again!\n");
    else if(m>=40 && m<50)
        printf("Small! Press any key to try again!\n");
    else if(m>70 && m<=80)
        printf("Big! Press any key to try again!\n");
    else if(m>=1 && m<40)
        printf("Too Small! Press any key to try again!\n");
    else if(m>80 && m<=100)
        printf("Too Bigger! Press any key to try again!\n");
    else if(m=60)printf("OK! You are right! Bye Bye!\n");
    }
}
搜索更多相关主题的帖子: between include please number return 
2014-03-16 14:48
蚕头燕尾
Rank: 10Rank: 10Rank: 10
来 自:Gryffindo
等 级:贵宾
威 望:12
帖 子:734
专家分:1546
注 册:2013-3-24
得分:0 
scanf("%d",m);

就凭这一点,你敢说你的程序编译能通过?!


学习编程,为的是表达自己的思想,而不是被别人的思想所禁锢。要先明白自己想干嘛,而不要先问别人让你干嘛。               

                                                                                                                    Black Cat      Hello Tomorrow~
2014-03-16 23:42
蚕头燕尾
Rank: 10Rank: 10Rank: 10
来 自:Gryffindo
等 级:贵宾
威 望:12
帖 子:734
专家分:1546
注 册:2013-3-24
得分:0 
另外,感觉你的这个程序的逻辑有点问题

建议你最好先想清楚这个问题到底是怎么个事儿?

起码你的循环用的就不太对。。


学习编程,为的是表达自己的思想,而不是被别人的思想所禁锢。要先明白自己想干嘛,而不要先问别人让你干嘛。               

                                                                                                                    Black Cat      Hello Tomorrow~
2014-03-16 23:43



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




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

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