fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int testy, liczby;
  7.  
  8. float sortowanie(float odl[], int liczby)
  9. {
  10. int n=0;
  11. float odl_mix[liczby-1];
  12. for (int i=0; i<liczby; i++)
  13. {
  14. if (odl[i]>odl[i+1])
  15. {
  16. odl_mix[i]=odl[i+1];
  17. odl_mix[i+1]=odl[i];
  18. n=1;
  19. }
  20. else odl_mix[i]=odl[i];
  21. }
  22. if (n==0) return odl_mix;
  23. else sortowanie(odl_mix, liczby);
  24. }
  25.  
  26. int main()
  27. {
  28. cin>>testy;
  29. for (int i=0; i<testy; i++)
  30. {
  31. cin>>liczby;
  32. string nazwa[liczby-1], nazwa_mix[liczby-1];
  33. float odl[liczby-1], odl_mix[liczby-1];
  34. int x[liczby-1], y[liczby-1], x_mix[liczby-1], y_mix[liczby-1];
  35. for (int i=0; i<liczby; i++)
  36. {
  37. cin>>nazwa[i]>>x[i]>>y[i];
  38. if (x[i]<0) x[i]=x[i]*(-1);
  39. if (y[i]<0) y[i]=y[i]*(-1);
  40. odl[i]= sqrt((x*x)+(y*y));
  41. }
  42. odl_mix=sortowanie(odl, liczby);
  43. for (int i=0; i<liczby; i++)
  44. {
  45. for (int j=0; j<liczby; j++)
  46. {
  47. if (odl[i]==odl_mix[j])
  48. {
  49. nazwa_mix[j]=nazwa[i];
  50. x_mix[j]=x[i];
  51. y_mix[j]=y[i];
  52. }
  53. }
  54. for (int i=0; i<liczby; i++)
  55. {
  56. cout<<nazwa_mix[i]<<" "<<x_mix[i]<<" "<<y_mix[i]<<endl;
  57. }
  58. }
  59. return 0;
  60. }
  61.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'float sortowanie(float*, int)':
prog.cpp:22:19: error: cannot convert 'float*' to 'float' in return
  if (n==0) return odl_mix;
                   ^
prog.cpp: In function 'int main()':
prog.cpp:40:25: error: invalid operands of types 'int [liczby]' and 'int [liczby]' to binary 'operator*'
         odl[i]= sqrt((x*x)+(y*y));
                         ^
prog.cpp:40:31: error: invalid operands of types 'int [liczby]' and 'int [liczby]' to binary 'operator*'
         odl[i]= sqrt((x*x)+(y*y));
                               ^
prog.cpp:42:12: error: incompatible types in assignment of 'float' to 'float [liczby]'
     odl_mix=sortowanie(odl, liczby);
            ^
prog.cpp:60:1: error: expected '}' at end of input
 }
 ^
stdout
Standard output is empty