Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- int count;
- cin >> count;
- vector<pair<int, string>> people;
- for (int i = 0; i < count; ++i) {
- string name;
- int age;
- cin >> name >> age;
- people.push_back({age, name});
- // сохраните в вектор пар
- }
- sort(people.begin(), people.end());
- reverse(people.begin(), people.end());
- for(auto& [age, name] : people){
- cout<<name<<endl;
- }
- // выведите только имена в порядке убывания возраста
- // Jack
- // John
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment