Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
542 B
0
Indexable
Never
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <cmath>
struct xyr {
	int x;
	int y;
	double r;
};
bool comp(xyr &a, xyr &b) {
	if (a.r > b.r) return 1;
	else return 0;
}
using namespace std;
int main()
{
	int n, i;
	cin >> n;
	vector<xyr> xyrr(n);
	for (i = 0; i < n; i++)
	{
		cin >> xyrr[i].x >> xyrr[i].y;
		xyrr[i].r = sqrt(xyrr[i].x * xyrr[i].x + xyrr[i].y * xyrr[i].y);
	}
	sort(xyrr.begin(), xyrr.end(), comp);
	for (auto c : xyrr) cout << c.x << ' ' << c.y << endl;
}