帮忙看看这道c++

来源:百度知道 编辑:UC知道 时间:2024/06/04 04:34:02
用结构数组实现学生成绩统计各功能。
某班有N(N<=30)个学生,共开设5门课程,分别用三个函数实现如下功能:
⑴求第一门课程的平均分;
⑵找出有2门及2门以上不及格的学生,并输出其学号;
⑶找出平均成绩在90分以上的学生,输出他们的学号。
Input
第一行为一个整数N,表示本班共N个人,接下来的N行中每行包含一个学生的信息,包括学号、课程1成绩、课程2成绩、课程3成绩、课程4成绩、课程5成绩。
Output/
输出共三行:第一行为本班第一门课程的平均成绩。(保留小数点后两位)
第二行为有2门及2门以上不及格的学生的学号,各学号之间用空格分隔。
第三行为平均成绩在90分以上的学生的学号, 各学号之间用空格分隔。
输入
3
070001 90 80 85 50 42
070002 93 95 90 88 92
070003 98 92 84 90 91
输出
93.67
070001
070002 070003

#include<iostream.h>
#include<iomanip.h>
struct student
{
char num[10];
int c1,c2,c3,c4,c5;
int ave;
}stu[30];

int main()
{
int n=0,c1_sum=0;
cout<<"请输入要录入记录数:\n";
cin>>n;
for(int i=0;i<n;i++)
{
cin>>stu[i].num>>stu[i].c1>>stu[i].c2>>stu[i].c3 >>stu[i].c4>>stu[i].c5;
c1_sum+=stu[i].c1;
stu[i].ave=(stu[i].c1 +stu[i].c2 +stu[i].c3 +stu[i].c4 +stu[i].c5 )/5;
}
cout<<setiosflags(ios::fixed)<< setprecision(2)<<(float(c1_sum)/n)<<endl;
for(int j=0;j<n;j++)
{
int k=0;
if(stu[j].c1<60)k++;
if(stu[j].c2<60)k++;
if(stu[j].c3<60)k++;
if(stu[j].c4<60)k++;
if(stu[j].c5<60)k++;
if (k>1)cout<<stu[j].num<<" ";
}
cout<<endl;
for(int m=0;m<n;m++)
{
i