哪位大哥大姐帮我做下这个,谢谢
描述:给定一个百分制成绩,判断其等级并输出。分数大于等于90分,输出A,小于90大于等于80,输出B,小于80大于等于60,输出C,小于60,输出D。.
输入:
N,N为一百分制成绩(0<=N<=100)
输出:
成绩的等级,最后输出一回车
输入样例:
85
输出样例:
B
#include<stdio.h> main() { int a; printf("请输入分数a。\n"); scanf("%d",&a); switch(a/10) { case 10: case 9: printf("分数%d对应等级是A\n",a);break; case 8: printf("分数%d对应等级是B\n",a);break; case 7: case 6: printf("分数%d对应等级是C\n",a);break; case 5: case 4: case 3: case 2: case 1: case 0:printf("分数%d对应等级是D\n",a);break; } }不知道这样合不合适?
main() { int score,grade; printf("please lnput a scaore(0~100):"); scanf("%d",&score); grade = score/10; /*将成绩整除以10,转化成switch语句的case标号*/ switch(grade); { case 10: case 9:printf("grade= A\n");break; /*标号10和9都执行本行的2条语句 */ case 8: case 7:printf("grade=B\n");break; case 6:printf("grade=C\n");break; case 5: case 4: case 3: case 2: case 1: case 0:printf("grade=D\n);breat;//修改下位case 0:printf("grade=D\n);break;打字的时候小心点呵呵 default:printf("the score is out of range!\n"); /* 成绩超出范围时 提示出错*/ } }呵呵很长