输入一个学生成绩,按A,B,C,D,E分出成绩的等级

代码如下:

# define _CRT_SECURE_WARINGS
# include<stdio.h>
# include<windows.h>
void test1()
{
unsigned int Score;                                  /*定义为不规则整型,在输入小于0的分数就能跳到提示页面,输入学生分数Score*/
    printf("please input a student score:");
    scanf("%d", &Score);

    printf("This student score belong to ");
    switch(Score / 10)                               /*按10分为一个阶梯把100分分为10段,依次排列*/
    {
    case 0: 
    case 1: printf("belong to E\n");break;
    case 2: 
    case 3: 
    case 4: 
    case 5: printf("belong to E\n"); break;
    case 6: printf("belong to D\n"); break;
    case 7: printf("belong to C\n"); break;
    case 8: printf("belong to B\n"); break;
    case 9: printf("belong to A\n"); break;
    case 10: 
    default: printf("please input a score more then zero and less then one hundred\n"); break;
    }
}
test2()
{
    int score, grade, sgr;                                       /*定义输入学生分数为SCORE,grade为分级,sgr等于每次键盘输入的分数*/
    printf("please input a student score: ");
    while(grade)
    {
        sgr = scanf("%d", &score);
        if (sgr)
        {
            if (score >= 90) printf("the student score belong to A");
            else if (score >= 80) printf("the student score belong to B");
            else if (score >= 70) printf("the student score belong to C");
            else if (score >= 60) printf("the student score belong to D");
            else printf("the student score belong to E");
        }
        else break;
    }
    return 0;

}
void main()
{
    test1();
    system("pause");
    return EXIT_SUCCESS;
}
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值