C++结构体问题,不会码??

有 10 个学生,每个学生的数据包括学号、姓名、3 门课的成绩, 从键盘输入10 个学生的数据,要求打印出 3 门课的总平均成绩,并计算出每人的平均成绩?

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct Student
{
    int num;
    string name;
    float score[3];
    float aver;
};
void input(Student *s, int n);
void average(Student *s, int n);
void high(Student *s, int n);
int main()
{
    Student stu[10], *st=stu;
    input(st, 10);
    average(st, 10);
    high(st, 10);
    system("pause");
    return 0;
}
void input(Student *s, int n)
{
    Student *p;
    int i, j;
    for (p=s, i=0; p<s+n; p++, i++){
        cout<<"Please enter No."<<i+1<<" student num, name, score: ";
        cin>>p->num>>p->name;
        for (j=0; j<3; cin>>p->score[j++]);
    }
}
void average(Student *s, int n)
{
    Student *p;
    int i;
    float sum, ave=0.0;
    for (p=s; p<s+n; p++){
        sum=0.0;
        for (i=0; i<3; sum+=p->score[i++]);
        p->aver=(sum/3);
        ave+=p->aver;
    }
    cout<<"Average= "<<ave/n<<endl;
}
void high(Student *s, int n)
{
    Student *p, *h;
    float high;
    int i;
    for (p=s, h=p, high=p->aver; p<s+n; p++)
        if (p->aver>high){
            high=p->aver;
            h=p;
        }
    cout<<"Highest student info: "<<h->num<<' '<<h->name<<' ';
    for (i=0; i<3; cout<<h->score[i++]<<' ');
    cout<<h->aver<<endl;
}

如果对你有帮助,可以点击我这个回答右上方的【采纳】按钮,给我个采纳吗,谢谢