#include <stdio.h>

int main() {
    float score;
    printf("请输入学生的成绩:");
    scanf("%f", &score);

    if (score < 60) {
        printf("该成绩的等级为D\n");
    } else if (score < 70) {
        printf("该成绩的等级为C\n");
    } else if (score < 80) {
        printf("该成绩的等级为B\n");
    } else if (score <= 100) {
        printf("该成绩的等级为A\n");
    } else {
        printf("输入的成绩不合法!\n");
    }

    return 0;
}

程序执行时,先提示输入学生的成绩,然后通过 scanf 函数读取输入的成绩值。接着,用 if 语句判断成绩所属的等级,并输出相应的等级。如果输入的成绩不在 0~100 之间,则输出提示信息。

C语言实现学生成绩等级评定

原文地址: https://www.cveoy.top/t/topic/npe6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录