fork(2) download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <algorithm>
  4.  
  5. class Punkt
  6. {
  7. char nazwa[11];
  8. int x,y;
  9. public:
  10. void wczytaj()
  11. {
  12. scanf("%s%d%d",&nazwa,&x,&y);
  13. }
  14. void wyswietl()
  15. {
  16. printf("%s %d %d\n",nazwa,x,y);
  17. }
  18. bool operator < (const Punkt &a)const
  19. {
  20. return sqrt(x*x+y*y)<sqrt(a.x*a.x+a.y*a.y);
  21. }
  22. };
  23.  
  24.  
  25. int main()
  26. {
  27. int test,ile;
  28. scanf("%d",&test);
  29. while(test--)
  30. {
  31. scanf("%d",&ile);
  32. Punkt tab[ile];
  33. for(int i=0; i <ile; ++i)
  34. {
  35. tab[i].wczytaj();
  36. }
  37. std::sort(tab,tab+ile-1);
  38. for(int i=0; i<ile; ++i)
  39. {
  40. tab[i].wyswietl();
  41. }
  42. printf("\n");
  43.  
  44. }
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 4364KB
stdin
2
3
A 0 0
C 5 5
B 1 -1

1 
X 1 1
stdout
A 0 0
C 5 5
B 1 -1

X 1 1