#include #include using namespace std; struct Point { int x; int y; double diagonal; }; double computeDiagonal(int x, int y) { double d = sqrt(x*x + y*y); return d; } void sort(Point *a, int n) { for (int i = 0; i < n-1; i++) for (int j = 0; j < n-1; j++) if (a[j].diagonal > a[j+1].diagonal) { Point buf = a[j]; a[j] = a[j+1]; a[j+1] = buf; } } int main() { int n; cout << "Enter count of points: "; cin >> n; Point *point = new Point [n]; cout << "Enter coordinates of points: " << endl; for (int i = 0; i < n; i++) cin >> point[i].x >> point[i].y; for (int i = 0; i < n; i++) point[i].diagonal = computeDiagonal(point[i].x, point[i].y); sort(point, n); for (int i = 0; i < n; i++) cout << point[i].x << " " << point[i].y << endl; return 0; }