A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 马志华 中级黑马   /  2014-12-7 21:55  /  1019 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

#include <stdio.h>
int main()
{
    //1提示输入
    printf("请输入分数:\n");
   
    //2接收输入
    int score;
    scanf("%d\n",&score);
   
    //3判断等级
    if (score>=90 && score<=100)
    {
        printf("A\n");
    }
    if (score>=80 && score<=89)
    {
        printf("B\n");
    }
    if (score>=70 && score<=79)
    {
        printf("C\n");
    }
    if (score>=60 && score<=69)
    {
        printf("D\n");
    }
    if (score<=59)
    {
        printf("E\n");
    }


    return 0;
}

4 个回复

倒序浏览
scanf("%d", &score);
不要写/n,否则屏蔽了回车
回复 使用道具 举报
明白了,谢啦
回复 使用道具 举报
scanf()函数里面不能写"\n",这个老师视频中有讲到的~~!
回复 使用道具 举报
code]#include <stdio.h>
int main()
{
    //1提示输入
    printf("请输入分数:\n");
    //2接收输入
    int score;
    scanf("%d",&score);
    //3判断等级
    if (score>=90 && score<=100)
    {
        printf("A\n");
    }
   else  if (score>=80 && score<=89)
    {
        printf("B\n");
    }
   else  if (score>=70 && score<=79)
    {
        printf("C\n");
    }
   else  if (score>=60 && score<=69)
    {
        printf("D\n");
    }
    else if (score<=59)
    {
        printf("E\n");
    }
    return 0;
[/code]
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马