#include <iostream> #include <algorithm> #include <string.h> using namespace std;
int n,k; Template<class t>//class display:public binary_function<t, t,bool>//{//public://Void operator () (Con
St t& A)//{//cout<<a<<endl;//}//};
Class Stud {public:void input ();
void Add ();
void Dele ();
void Change ();
void sorts ();
void Maxn ();
void Show ();
int score1;
friend BOOL CMP (stud A,stud b);
Private:long long num;
Char name[60];
char sex;
int score;
int flag;
}S[1000];
void Stud::show () {cout<< "score info" <<endl; for (int i=1;i<=n;i++) {if (S[i].flag) cout<<s[i].num<< "<<s[i].name<<" &L
t;<s[i].sex<< "" <<s[i].score<<endl;
} void Stud::input () {cout<< "Please enter student number" <<endl;
cin>>n;
K=n; for (int i=1;i<=n;i++) {cin>>s[i].num>>s[i].name>>s[i].sex>>s[i].score;
s[i].flag=1;
cout<< "Enter Complete" <<endl;
} void Stud::add () {int A;
cout<< "Please enter the number of students to add" <<endl;
cin>>a;
N=n+a;
cout<< "Please enter the student's number, name, gender, score" <<endl;
for (int i=k+1;i<=n;i++) {cin>>s[i].num>>s[i].name>>s[i].sex>>s[i].score;
s[i].flag=1;
S[i].score1=s[i].score;
} cout<< "Add Success" <<endl;
} void Stud::d ele () {int B;
cout<< "Please enter the student number you want to delete" <<endl;
cin>>b;
for (int i=1;i<=n;i++) {if (s[i].num==b) {s[i].flag=0;
} cout<< "Delete Success" <<endl;
} void Stud::change () {int c,k,choice;
int NewsCore;
Char newname[60];
Char Newsex;
cout<< "Please enter the student number for which you want to modify the information" <<endl;
cin>>c;
for (int i=1;i<=n;i++) {if (s[i].num==c) {k=i;
Break
}
} cout<< "Please select options to modify" <<endl;
cout<< "1: Name modification" <<endl;
cout<< "2 Sex modification" <<endl;
cout<< "3 Grades Modified" <<endl;
cin>>choice;
if (choice==1) {cout<< "Please enter a new name" <<endl;
cin>>newname;
strcpy (S[k].name,newname);
else if (choice==2) {cout<< "Please enter a new gender" <<endl;
cin>>newsex;
S[k].sex=newsex;
else if (choice==3) {cout<< "Please enter a new score" <<endl;
cin>>newscore;
S[k].score=newscore;
cout<< "modified successfully" <<endl; ///Sort function//inline bool operator> (const stud& A, const stud& b)//{//Return A.get () > B.get ();////// /template<class t>//class greater:public binary_function<t, t,bool>//{//public://bool Operator () (cons
T t& A, const t& B)//{//return a > B;//}//}; void Stud::sorts ()//{//cout<< "sort" <<endl;// Sort (Avec.begin (), Avec.end (),greater<stud> ());
For_each (Avec.begin (), Avec.end (), display<stud> ());
cout<< "Sort Complete" <<endl;
}////bool cmp (const stud &A,CONST stud &B)//{//Return a.score1>b.score1;//} BOOL CMP (stud A,stud B)
{return a.score>b.score;} void Stud::sorts () {sort (s+1,s+n+1,cmp); for (int i=1;i<=n;i++) {if (S[i].flag) cout<<s[i].num<< "<<s[i].name<<" &L
t;<s[i].sex<< "" <<s[i].score<<endl;
} void Stud::maxn () {cout<< "The best student:" <<endl;
Sort (s+1,s+n+1,cmp);
cout<<s[1].name<<endl;
int main () {int key;
Stud T1;
cout<< "-----Student Information Management System-----" <<endl;
cout<< "1: Input Info" <<endl; cout<< "2: Adding Information" <<endl;
cout<< "3: Delete Info" <<endl;
cout<< "4: Modify Information" <<endl;
cout<< "5: Ranking of grades" <<endl;
cout<< "6: Output First Name" <<endl;
cout<< "7: Output Score" <<endl;
cout<< "8: Any key exit" <<endl;
while (Cin>>key) {if (key==1) {t1.input ();
else if (key==2) {t1.add ();
else if (key==3) {T1.dele ();
else if (key==4) {t1.change ();
else if (key==5) {t1.sorts ();
else if (key==6) {T1.MAXN ();
else if (key==7) {t1.show ();
else return 0;
} return 0; }Record ^ _ ^