| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 852 人关注过本帖
标题:新手,请教。。。
只看楼主 加入收藏
tehi
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2008-8-15
收藏
 问题点数:0 回复次数:7 
新手,请教。。。
main()
    {
    int score;
    scanf("%d",&score);
    if(score<0&&score>100)printf("you put a wrong score.");
    else if(score<60)printf("you score is E.");
    else if(score>=60&&score<70)printf("you score is D.");
    else if(score>=70&&score<80)printf("you score is B.");
    else if(score>=80&&score<90)printf("you score is C.");
    else printf("you score is A.");
    }
输入大于100的数 还是显示you score is A. 不知道怎么回事 请指教。
谢谢。
搜索更多相关主题的帖子: score int wrong 
2008-08-15 12:44
wbxnj
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:24
专家分:0
注 册:2008-8-13
收藏
得分:0 
#include<stdio.h>
main()
{
    int score;
    scanf("%d",&score);
    if(score<0 || score>100)
        printf("you put a wrong score.");
    else
        if(score<60)
            printf("you score is E.");
   
        else
            if(score>=60&&score<70)
                printf("you score is D.");
   
            else
                if(score>=70&&score<80)
                    printf("you score is B.");
   
                else
                    if(score>=80&&score<90)
                        printf("you score is C.");
   
                    else
                        printf("you score is A.");
}
2008-08-15 14:45
wbxnj
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:24
专家分:0
注 册:2008-8-13
收藏
得分:0 
if(score<0&&score>100) 问题在这行
正确的是:
if(score<0 || score>100)
2008-08-15 14:46
tehi
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2008-8-15
收藏
得分:0 
谢谢 谢谢
我也想明白为什么错了。
2008-08-15 17:32
csynyk
Rank: 1
等 级:新手上路
威 望:1
帖 子:114
专家分:0
注 册:2008-8-9
收藏
得分:0 
score<0&&score>100  。。。。?
虽然是计算机,可也找不出符合条件的啊!

http://blog./csynyk
2008-08-15 18:05
☆Jony☆
Rank: 1
等 级:新手上路
帖 子:70
专家分:0
注 册:2008-2-22
收藏
得分:0 
程序的第五行if(score<0&&score>100)应改为if(score<0||score>100)

☆滴水穿石☆水滴石穿☆
QQ:920633639
2008-08-15 19:12
raymond1010
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2008-8-9
收藏
得分:0 
3楼正解
2008-08-15 23:14
zhoufanking
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-8-10
收藏
得分:0 
if(score<0||score>100)判断完成后如果socre不符合要求应return,否则就转到printf("you score is E.")或最后一句else printf("you score is A.");
2008-08-16 09:23
快速回复:新手,请教。。。
数据加载中...
 
   



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

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