某大学全校都开设C语言课程,每学年结束都按成绩进行统计和分析。请编写程序,输入优秀、良好、中等、及格和不及格的人数,输出成绩分析表。
输入样例
684 3290 7512 10958 37
输出样例
- Rank Number Ratio
- -----------------------
- Excellent 684 3.0%
- Good 3290 14.6%
- Medium 7512 33.4%
- Pass 10958 48.7%
- Fail 37 0.2%
- -----------------------
- Total 22481 100.0%
代码
- #include
- int main()
- {
- int E,G,M,P,F,S;
- scanf("%d %d %d %d %d",&E,&G,&M,&P,&F);
- S=E+G+M+P+F;
- printf("Rank Number Ratio\n");
- printf("-----------------------\n");
- printf("Excellent %6d %4.1f%\n",E,(double)E*100/(double)S);
- printf("Good %6d %4.1f%\n",G,(double)G*100/(double)S);
- printf("Medium %6d %4.1f%\n",M,(double)M*100/(double)S);
- printf("Pass %6d %4.1f%\n",P,(double)P*100/(double)S);
- printf("Fail %6d %4.1f%\n",F,(double)F*100/(double)S);
- printf("-----------------------\n");
- printf("Total %6d 100.0%\n",S);
- return 0;
- }
'运行