Məsələlər
Сортировка точек по координатам
Где вводится n?
include<bits/stdc++.h>
using namespace std; struct Point { int x,y; }; bool comp(Point a,Point b) { if(a.x!=b.x) { return a.x<b.x; }
if(a.y!=b.y) { return a.y>b.y; } } int main() { vector<Point>v; int x,y; while(cin>>x>>y) { v.push_back({x,y});
}
sort(v.begin(),v.end(),comp);
for(int i=0; i<v.size(); i++)
{
cout<<v[i].x<<" "<<v[i].y<<endl;
}
}
include <bits/stdc++.h>
using namespace std;
typedef long long ll; typedef long double ld;
bool mySort(pair<int, int> a, pair<int, int> b) { if (a.first != b.first) return a.first < b.first; else return a.second > b.second; }
void solve() {
int a, b;
vector<pair<int, int>> v;
while (cin >> a >> b)
v.push_back({ a, b });
sort(v.begin(), v.end(), mySort);
for (auto p : v)
cout << p.first << " " << p.second << endl;
}
int main() { iosbase::syncwith_stdio(false), cin.tie(NULL), cout.tie(NULL);
ifdef _DEBUG
freopen("input-1.txt", "r", stdin);
endif
solve();
return 0;
} //hacked by **