C++简单的成绩统计问题

来源:百度知道 编辑:UC知道 时间:2024/06/10 00:21:09
要求:1、学生数由用户输入;
2、每学生有:English,math,computer三门成绩,均由用户输入,输入一人换一行再输;
3、按平均分高至低输出,此时每行附上平均分;
4、C++实现。要用到类,构造与析构函数

追加高分!!再谢再谢

#include <iostream>
using namespace std;

struct StuInfo//学生信息结构体
{
float English;
float Math;
float Computer;
float Average;
int Num;
};
void swap(StuInfo &a, StuInfo &b )
{
StuInfo *temp=new StuInfo;
temp->Average=a.Average; temp->Computer=a.Computer;temp->English=a.English;temp->Math=a.Math;temp->Num=a.Num;
a.Average=b.Average;a.Computer=b.Computer;a.English=b.English;a.Math=b.Math;a.Num=b.Num;
b.Average=temp->Average;b.Computer=temp->Computer;b.English=temp->English;b.Math=temp->Math;b.Num=temp->Num;
}
class Student//学生统计类
{
public:
Student(int num);
~Student();
void Print();
void Input();
void sum();
private:
void SortByAverage();
int m_Num;
StuInfo *m_stuinfo;
};
Student::Student(int num)
{

m_Nu