pta 升级或留级某中学开设语文,数学,物理化学和外语等五门课程。60分及以下为不及格,60分以上为及格。请编写函数,根据学生五门课的成绩计算不及格的门数。输入五门课的成绩,若全部及格则输出升级 不及格门数只有一门。则输出补考。若不及格门数为两到三门。则输出留级。若不及格数达到或超过四门。则输出退学。
#include<stdio.h>
int Failed(double chn,double math,double phy,double chem,double fore);
int main()
{
double chn,math,phy,chem,fore;
scanf("%lg",&chn);
scanf("%lg",&math);
scanf("%lg",&phy);
scanf("%lg",&chem);
scanf("%lg",&fore);
switch(Failed(chn,math,phy,chem,fore))
{
case 0:
puts("升级");break;
case 1:
puts("补考");break;
case 2:
case 3:
puts("留级");break;
deafult:
puts("退学");break;
}
return 0;
}
int Failed(double chn,double math,double phy,double chem,double fore)
{
int a,cnt=0;
if(chn<60)
cnt++;
if(math<60)
cnt++;
if(phy<60)
cnt++;
if(chem<60)
cnt++;
if(fore<60)
cnt++;
return cnt;
}