#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int main()
{
static char c, m;
float n;
system("color 3F");
printf("请输入成绩或等级:\n");
scanf("%f", &n);
scanf("%c", &c);
switch (c)
{
case 'a':
case 'A':printf("属于分数段80~90\n"); return;
case 'b':
case 'B':printf("属于分数段70~80\n"); return;
case 'c':
case 'C':printf("属于分数段60~70\n"); return;
case 'd':
case 'D':printf("分数不及格\n"); return;
default:break;
}
while (n >= 0)
{
if (n > 100)
{
printf("输入有误\n");
return 0;
}
else if (n >= 90) m = 'A';
else if (n >= 80) m = 'B';
else if (n >= 60) m = 'C';
else if (n < 60) m = 'D';
printf("等级为:%c\n", m);
return 0;
}
printf("输入有误\n");
return 0;
}
标签:case,百分制,转换,else,分数段,printf,return,80,成绩 From: https://blog.51cto.com/u_16073189/6355017