Current location - Plastic Surgery and Aesthetics Network - Jewelry brand - Sell jewelry
Sell jewelry
# include & ltiostream & gt

# include & lt string & gt

# include & lt algorithm & gt

# include & ltvector & gt

Use namespace std

Class students

{

Public:

Student(string vname,int vscore):name(vname),score(vscore){}

Friends AllStudent

Private:

String name;

Int score;

};

The whole class {

Public:

void sortScore(){sort(vs.begin(),vs.end(),[](Student & amp; Student & AMPB) {return a.score > B. scores; }); }

void inputStudent(string name,int score){ vs . push _ back(Student(name,score)); }

void show score(){ for(auto it = vs . begin(); It! = vs . end(); it++)cout & lt; & lt it-> Name & lt& lt,< it-> Score & lt& ltendl}

Private:

Vector & lt student & gtvs;;

};

int main(){

int num

Cout & lt& lt "Enter the number of people"

CIN & gt; & gtnum

AllStudent as

Cout & lt& lt "Enter your name and rank as Zhang San 100"

for(int I = 0; I & ltnumi++){

String name; Int score;

Cout & lt& lt "first"

CIN & gt; & gt name & gt& gt score;

As.inputStudent (name, score);

}

as . sort score();

Cout & lt& lt "Rank from high to low:"

Returns 0;

}