Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 1.6.1E.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- /* Няколко точки в равнината са зададени чрез координатите си - цели числа.
- * Да се подредят точките в нарастващ ред спрямо квадрата на разстоянието
- * до началото на координатната система.
- */
- #include <algorithm>
- #include <iostream>
- #include<tuple> // for tuple
- #define endl '\n'
- using namespace std;
- int distance(int x, int y)
- {
- return x * x + y * y;
- }
- tuple <int, int, int> points[10];
- int main()
- {
- int n, dist, x, y;
- cin >> n;
- for(int i =0; i<n;i++)
- {
- cin >> x >> y;
- points[i] = { distance(x,y), x, y };
- }
- sort(points, points + n);
- for(int i =0; i<n;i++)
- {
- tie(dist, x, y) = points[i];
- cout << x << " " << y << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment