#include <iostream> #include <string> #include <vector>using namespace std;//Student class student{ Private:string name; name int age; Age string Code; Study number int Nianji; age int grade; Result public://constructor Student () {} student (string na, int A, string c, int n, int g): Name (NA), age (a), code (c), Nianj I (n), Grade (g) {} string GetName () {return name;} void SetName (String na) {this->name = na;} int Getage () {return age;} void setage (int age) {this->age = age;} String GetCode () {return code;} void Setcode (string c) {This->code = C;} int Getnianji () {return Nianji;} void Setnianji (int nj) {This->nianji = NJ;} int Getgrade () {return grade;} void Setgrade (int g) {this->grade = g;} /* student& operator = (Const student& s) {name = S.name; Name age = S.age; Age code = S.code; Study number Nianji = S.niAnji; Age grade = S.grade; result return *this; }*/};//Teacher class teacher{private:string name; name int age; Age int Gonghao; Work number int classtime; hours int money; Lesson Fee Public://constructor Teacher () {} teacher (string na, int a, int gh, int ct, int m): Name (NA), age (a), Gonghao (GH), C Lasstime (CT), Money (m) {} string GetName () {return name;} void SetName (String na) {this->name = na;} int Getage () {return age;} void setage (int age) {this->age = age;} int Getgonghao () {return gonghao;} void Setgonghao (int gh) {This->gonghao = GH;} int Getclasstime () {return classtime;} void setclasstime (int ct) {this->classtime = ct;} int Getmoney () {return money;} void Setmoney (int m) {This->money = m;}};/ /Employee class employee{private:string name; name int age; Age int Gonghao; Work number int money; Monthly public://Constructor employee () {} employee (string na, int a, int gh, int m): Name (NA), age (a), Gonghao (GH), Money (m) {} string get Name () {return name;} void SetName (String na) {this->name = na;} int Getage () {return age;} void setage (int age) {this->age = age;} int Getgonghao () {return gonghao;} void Setgonghao (int gh) {This->gonghao = GH;} int Getmoney () {return money;} void Setmoney (int m) {This->money = m;}}; void Maopao (vector<student> vs, vector<student> &vgai) {student Temp1, temp2; Sort according to the score, then put into the vector, find the smallest and then remove it to be able to (int i = 0; vs.size () > 0;) {//Take the current first one at a time, because I will always delete the class temp1=vs[i]; And back comparison for (auto J=vs.begin () +1; J! = Vs.end (); ++j) {temp2=*j; if (Temp1.getgrade () <temp2.getgrade ()) {//If the first one is small, then swap until the largest temp1=temp2 is found; }}//The first layer loop is completed, find the current largest, put into Vgai first//cout<<temp1.getgrade () << "XX" <<endl; Vgai.push_back (TEMP1); The current temp1 is removed from vs until the VS is vacated vector<student>::iterator ITR = Vs.begin (); while (ITR! = Vs.end ()) {if (itr-> GetName () = = Temp1.getname ()) {vs.erase (ITR);//delete element with value 3 break;} ++itr;} }}void print (vector<teacher> vt) {const string NAME1 = "Higher garbage teacher Name", NAME2 = "Number of teacher name", NAME3 = "English teacher name", cout << "various subjects The teacher's information is: "<< endl;cout <<" name \t\t age \ t work number \ t \ \ class fee \ t "<< endl;for (Auto it = Vt.begin (); It! = Vt.end (); + + It) {Teacher T = *it;string s = t.getname (); if (s = = NAME1 | | s = = NAME2 | | s = = NAME3) {cout << t.getname () << "\ T" << t.getage () << "\ T" << T.getgonghao () << "\ T" << t.getclasstime () << "\ T" < < T.getmoney () << Endl;}}} int main () {vector<student> vs, vgai; Student S1 ("MyName1", 19, "20130901001", 2, 98); Himself is the first, the default student S2 ("myName2", 19, "20130901002", 2, 94); Student S3 ("MyName3", 19, "20130901003 ", 2, 33); Student S4 ("MyName4", 19, "20130901004", 2, 45); Student S5 ("MyName5", 19, "20130901005", 2, 75); Student S6 ("MyName6", 19, "20130901006", 2, 12); Student S7 ("MyName7", 19, "20130901007", 2, 77); Student S8 ("MyName8", 19, "20130901008", 2, 33); Student S9 ("MyName9", 19, "20130901009", 2, 55); Student S10 ("MyName10", 19, "20130901010", 2, 78); Student S11 ("MyName11", 19, "20130901011", 2, 28); Student S12 ("MyName12", 19, "20130901012", 2, 58); Student S13 ("MyName13", 19, "20130901013", 2, 8); Student S14 ("MyName14", "20130901014", 2, +);//1-------------------------------------------------------------- ---------cout<< "My message is:" <<endl; cout<< "name \t\t age \ t study number \t\t grade \ T" <<endl; Cout<<s1.getname () << "\t\t" <<s1.getage () << "\ T" <<s1.getcode () << "\ T" <<s1.getnianji () << "\ T" <<s1.getgrade () <<endl; Output the nearest 10 bits, no database can only use this stupid method vs.pUsh_back (S1); Vs.push_back (S2); Vs.push_back (S3); Vs.push_back (S4); Vs.push_back (S5); Vs.push_back (S6); Vs.push_back (S7); Vs.push_back (S8); Vs.push_back (S9); Vs.push_back (S10); Vs.push_back (S11); Vs.push_back (S12); Vs.push_back (S13); Vs.push_back (S14); Vector<student>::iterator it = Vs.begin (); int count = 1; Count 10//2-----------------------------------------------------------------------cout<< "Back 10 bit Info" < <endl; while (It! = Vs.end () && count <=) {cout<<it->getname () << "" << It->getage () << "\ T" <<it->getcode () << "\ T" <<it->getnianji () << "\ T" <<it->getgrade () <<endl; ++it; ++count; }//3-----------------------------------------------------------------------Maopao (VS, Vgai); cout<<endl; cout<< "After sorting:" <<endl; Vector<student>::iterator it2 = Vgai.begin (); int Count2 = 1; Count of 10 while (it2! = Vgai.end ()) {cout<<it2->getname () << "" <<it2->get Age () << "\ T" <<it2->getcode () << "\ T" <<it2->getnianji () << "\ T" <& Lt;it2->getgrade () <<endl; ++it2; }//4-----------------------------------------------------------------------vector<teacher> vt;teacher T1 (" Higher garbage Teacher's name ", 60, 001, 2, 7000), T2 (" Number of teacher name "," 002, "" 9980 "), T3 (" English teacher's name ", 998, 003,), T4 (" The Teacher's name ", 004, 30, 700 0); Vt.push_back (T1), Vt.push_back (T2), Vt.push_back (T3), vt.push_back (T4);p rint (VT); Char c;cin>>c; return 0;}
A small question, the classmate asked me to help, I quickly wrote some, it is very messy, but if the database is still a bit of meaning
"A C + + program" Small Lesson Set