Advertisement
TwITe

Untitled

Aug 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. bool comp(const pair<int, int> &a, const pair<int, int> &b) {
  2.     if (a.second != b.second) {
  3.         return (a.second > b.second);
  4.     }
  5.     else {
  6.         return (a.first < b.first);
  7.     }
  8. }
  9.  
  10.  
  11. void task3() {
  12.     int n;
  13.     cin >> n;
  14.     vector <pair <int, int>> numbers(n);
  15.     for (int i = 0; i < n; i++) {
  16.         int current_in, current_result;
  17.         cin >> current_in >> current_result;
  18.         numbers[i] = { current_in, current_result };
  19.     }
  20.     sort(numbers.begin(), numbers.end(), comp);
  21.     for (auto i : numbers) {
  22.         cout << i.first << " " << i.second;
  23.         cout << endl;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement