嘿嘿code 2021-10-07 14:07 采纳率: 92.3%
浏览 21
已结题

c语言基础问题求解答

 输入某学生语文课程的成绩,输出该成绩的等级。判断规则为:如果成绩在90-100的范围内,则等级为A;若成绩在80-89的范围内,则等级为B;若成绩在70-79的范围内,则等级为C;若成绩在60-69的范围内,则等级为D;若少于60分,则等级为F。(要求:用switch语句实现。)

  • 写回答

1条回答 默认 最新

  • qzjhjxj 2021-10-07 14:45
    关注

    供参考:

    #include <stdio.h>
    int main()
    {
        int grades,mark;
        scanf("%d", &grades);
        mark = (grades >= 0 && grades<=100 ? grades/10 : -1);
        switch (mark)
        {
            case 10:
            case 9: printf("the score is %d, is A\n",grades);
                    break;
            case 8: printf("the score is %d, is B\n",grades);
                    break;
            case 7: printf("the score is %d, is C\n",grades);
                    break;
            case 6: printf("the score is %d, is D\n",grades);
                    break;
            case 5:
            case 4:
            case 3:
            case 2:
            case 1:
            case 0:printf("the score is %d, is F\n",grades);
                   break;
           default:printf("Error Enter!\n");
                   break;
        }
        return 0;
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月15日
  • 已采纳回答 10月7日
  • 创建了问题 10月7日

悬赏问题

  • ¥15 oracle数据库查询语句问题
  • ¥15 有没有c++绘制算法的佬们吗救孩一下
  • ¥15 android 蓝牙闪退
  • ¥15 绝缘子污秽comsol仿真参数
  • ¥15 Fatal error in Process MEMORY
  • ¥15 labelme生成的json有乱码?
  • ¥30 arduino vector defined in discarded section `.text' of wiring.c.o (symbol from plugin)
  • ¥20 如何训练大模型在复杂因素组成的系统中求得最优解
  • ¥15 关于#r语言#的问题:在进行倾向性评分匹配时,使用“match it"包提示”错误于eval(family$initialize): y值必需满足0 <= y <= 1“请问在进行PSM时
  • ¥45 求17位带符号原码乘法器verilog代码