Działający program.
#include <iostream> #include <algorithm> #include <cmath> using namespace std; class Punkt { string nazwa; int a,b; public: void wczytaj() { cin>>nazwa>>a>>b; } void wypisz() { cout<<nazwa<<""<<a<<""<<b<<endl; } bool operator < (const Punkt &x)const { return sqrt(pow(a,2)+pow(b,2)) < sqrt(pow(x.a,2)+pow(x.b,2)); } }; int main() { short liczba_testow,liczba_punktow; cin>>liczba_testow; while(liczba_testow) { cin>>liczba_punktow; Punkt pkt[1001]; for(int i=0; i<liczba_punktow; i++) { pkt[i].wczytaj(); } sort(pkt,pkt+liczba_punktow); for(int i=0; i<liczba_punktow; i++) { pkt[i].wypisz(); } cout<<endl; liczba_testow--; } return 0; }