编程统计全班学生成绩。要求每次用键盘输入一个学生的2门分数,

来源:百度知道 编辑:UC知道 时间:2024/05/24 22:41:21
编程统计全班学生成绩。要求每次用键盘输入一个学生的2门分数,计算输出每个学生的总分和平均分。如果平均大于等于85为优秀;60-85为通过。统计出成绩优秀的学生及及格学生的人数。

#include<iostream>
using namespace std;

void main()
{
int sub1,sub2,i=1,count1=0,count2=0,count3=0;

cout<<"input the "<<i<<" students two subjects score:"<<endl;
cin>>sub1>>sub2;
do{
float aver=0,sum=0;
aver=(sub1+sub2)/2;
if(aver>=85) count1++;
else if(aver<85&&aver>=60)
count2++;
else count3++;
i++;
cout<<"input the "<<i<<" students two subjects score,end by -1:"<<endl;
cin>>sub1;
if(sub1==-1)break;
else cin>>sub2;
}while(1);
cout<<"the excelent students' amount is: "<<count1<<endl;
cout<<"the passed students' amount is: "<<count2<<endl;
}

制作3列表格,A列一科成绩,B列另一科成