#include<iostream>
#include<string.h>
using namespace std;classCStudent{private:
int id;
string name;
int math;
int english;static int count;static int mathc;static int englishc;public:voidsetms(){
cout <<"name id math english"<< endl;
cin >> name >> id >> math >> english;
count++;
mathc = mathc + math;
englishc = englishc + english;}
int add(){return math + english;}voidoutms(){
cout <<"id"<<id << endl;
cout <<"math :"<< math << endl <<"english :"<< english << endl;}voidoutave(){
cout <<" math :"<< mathc << endl;
cout <<" english :"<< englishc << endl;
cout <<" count :"<< count << endl;
cout <<" math average :"<< mathc / count << endl;
cout <<" english average :"<< englishc / count << endl;}};
int CStudent::count =0;
int CStudent::mathc =0;
int CStudent::englishc =0;
int main(){
CStudent S[10],* p =newCStudent;;
int i, j, k =0;for(i =0; i <10; i++){S[i].setms();}for(j =0; j <9; j++){for(i =0; i <9- j; i++){if(S[i].add()>S[i +1].add()){*p =S[i];S[i]=S[i +1];S[i +1]=*p;}}}for(i =9; i >7; i--){S[i].outms();}delete p;return0;}
定义一个学生类CStudent,私有数据成员包括name (姓名)、id(学号)、math (数学成绩)t题目要求#include<iostream>#include<string.h>using namespace std;class CStudent{private: int id; string name; int math; int english; static int count; static int mathc; static int e