Napisałem więc od nowa... i znów rozwiązanie nie jest akceptowane. Gdzie popełniam błąd? Oto kod:
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
struct Point {
char name[11];
int x;
int y;
};
int compare(const void *v1, const void *v2) {
Point *p1 = (Point*)(v1);
Point *p2 = (Point*)(v2);
if(sqrt(p1->x*p1->x + p1->y*p1->y) < sqrt(p2->x*p2->x + p2->x*p2->y)) return -1;
if(sqrt(p1->x*p1->x + p1->y*p1->y) > sqrt(p2->x*p2->x + p2->x*p2->y)) return 1;
else return 0;
}
int main() {
unsigned t;
cin >> t;
Point tab[1000];
unsigned n;
for(int i = 0; i < t; ++i) {
cin >> n;
for(int j = 0; j < n; ++j) {
cin >> tab[j].name;
if(strlen(tab[j].name) > 10) return 1;
cin >> tab[j].x;
if(tab[j].x < -1000 || tab[j].x > 1000) return 1;
cin >> tab[j].y;
if(tab[j].y < -1000 || tab[j].y > 1000) return 1;
}
qsort(tab, n, sizeof(Point), compare);
for(int j = 0; j < n; ++j)
cout << tab[j].name << " " << tab[j].x << " " << tab[j].y << endl;
cout << endl;
}
return 0;
}