| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 250 人关注过本帖
标题:新手,请教。。。
收藏  订阅  推荐  打印 
tehi
Rank: 1
等级:新手上路
帖子:16
积分:290
注册:2008-8-15
新手,请教。。。

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-8-15 12:44
wbxnj
Rank: 1
来自:武汉
等级:新手上路
帖子:24
积分:364
注册:2008-8-13

#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-8-15 14:45
wbxnj
Rank: 1
来自:武汉
等级:新手上路
帖子:24
积分:364
注册:2008-8-13

if(score<0&&score>100) 问题在这行
正确的是:
if(score<0 || score>100)
2008-8-15 14:46
tehi
Rank: 1
等级:新手上路
帖子:16
积分:290
注册:2008-8-15

谢谢 谢谢
我也想明白为什么错了。
2008-8-15 17:32
csynyk
Rank: 2
等级:注册会员
威望:1
帖子:114
积分:1460
注册:2008-8-9

score<0&&score>100  。。。。?
虽然是计算机,可也找不出符合条件的啊!

http://blog.csdn.net/csynyk
2008-8-15 18:05
☆Jony☆
Rank: 2
等级:注册会员
帖子:66
积分:818
注册:2008-2-22

程序的第五行if(score<0&&score>100)应改为if(score<0||score>100)

☆滴水穿石☆水滴石穿☆
QQ:920633639
2008-8-15 19:12
raymond1010
Rank: 2
等级:注册会员
帖子:43
积分:566
注册:2008-8-9

3楼正解
2008-8-15 23:14
zhoufanking
Rank: 1
等级:新手上路
帖子:7
积分:172
注册:2008-8-10

if(score<0||score>100)判断完成后如果socre不符合要求应return,否则就转到printf("you score is E.")或最后一句else printf("you score is A.");
2008-8-16 09:23
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.052489 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved