C++语言编程请教

来源:百度知道 编辑:UC知道 时间:2024/05/23 16:38:12
如果某班有35名学生 共上四门课请编写一个程序完成以下工作
从键盘上输入每个学生的学号姓名四门课的成绩
求出每个学生的总成绩和平均成绩
求出全班四门课各处的平均成绩
输出班上总分最高和最低学生的学号总分和平均分数
排出最好分和最低分的学生资料
以下是我的写的一半程序
剩下的不太会了
希望大家帮我一下
要求用结构体还解决
本来想贴出自已写的一半的程序
可是太长了
没法贴出来
希望会有兄弟能帮个忙
因为有些地方想不通了

随便搞了一下,有些功能没实现,你自己加,不会太难了,
#include <iostream>
#include<iomanip>
using namespace std;
const int n=10;
struct student
{char num[6];
char name[8];
int score[4];
float avr;
}stu[n];

int main()
{int i,j,max,maxi,sum;
float average;
for(i=0;i<n;i++)
{cout<<"input scores of student"<<i+1<<endl;
cout<<"NO.:";
cin>>stu[i].num;
cout<<"name:";
cin>>stu[i].name;
for(j=0;j<=3;j++)
{cout<<"score"<<j+1<<":";
cin>>stu[i].score[j];
}
cout<<endl;
}
average=0;
max=0;
maxi=0;
for(i=0;i<n;i++)
{sum=0;
for(j=0;j<3;j++)
sum+=stu[i].score[j];
stu[i].avr=sum/3.0;
average+=stu[i].avr;
if(sum>max)
{max=sum;
maxi=i;
}
}
average/