❶ 一个班级有n名同学,编写程序实现将n个同学一门课程的期末成绩转换为等级制,并统计各等数,要求输入
void main()
{
int score;
int count[5]={0};
printf("please input your score:");
while (scanf("%d",&score) ==1)
{
int tmp = score/10;
switch(tmp)
{
case 10:
count[0]++;
break;
case 9:
count[0]++;
break;
case 8:
count[1]++;
break;
case 7:
count[2]++;
break;
case 6:
count[3]++;
break;
default:
count[4]++;
break;
}
printf("The result: \n");
printf("A(90-100):%d\n",count[0]);
printf("B(80-89):%d\n",count[1]);
printf("C(70-79):%d\n",count[2]);
printf("D(60-69):%d\n",count[3]);
printf("E(0-59):%d\n",count[4]);
}
}
❷ 初级c语言编程 百分制成绩转换成等级制
#include<stdio.h>
intmain()
{
intnumber=0;
scanf("%d",&number);
if(number>=90)
printf("优秀 ");
elseif(number>=80)
printf("良好 ");
elseif(number>=60)
printf("中等 ");
else
printf("不及格 ");
return0;
}
❸ C语言作业,百分制成绩转换成等级成绩编程
您好!很高兴为您解答。
程序如下:
#include <stdio.h>
int main()
{
int base_grade,extra_grade;
printf("请输入学生成绩(基本题和附加题,成绩为整数):");
scanf("%d%d",&base_grade,&extra_grade);
if(base_grade>100||base_grade<0||extra_grade>30||extra_grade<0)
{
printf("成绩不合法,请重新输入。\n");
return 0;
}
if((base_grade>84&&extra_grade>17)||(base_grade>74&&base_grade<85&&extra_grade>23))
{
printf("A+\n");
return 0;
}
else if((base_grade>84&&extra_grade<18)||(base_grade>74&&base_grade<85&&extra_grade<24&&extra_grade>17))
{
printf("A\n");
return 0;
}
else if(base_grade>74&&base_grade<85&&extra_grade<18)
{
printf("B\n");
return 0;
}
else if(base_grade<75&&base_grade>64)
{
printf("C\n");
return 0;
}
else if(base_grade<65&&base_grade>59)
{
printf("D\n");
return 0;
}
else
{
printf("F\n");
return 0;
}
}
已通过编译。运行正常~
如您满意,望采纳~谢谢~