fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int testy,testy2;
  7. int liczba[102];
  8. float wpisanych=0;
  9. float srednia=0;
  10. int suma=0;
  11. int boss;
  12.  
  13. int main()
  14. {
  15. cin>>testy;
  16. for(int i=1; i<=testy; i++)
  17. {
  18. cin>>testy2;
  19. for(int i=0; i<testy2; i++)
  20. {
  21. cin>>liczba[i];
  22. wpisanych++;
  23. suma+=liczba[i];
  24. }
  25. srednia=suma/wpisanych;
  26. boss=liczba[0];
  27. for(int i=0; i<testy2; i++)
  28. {
  29. if((fabs(liczba[i]-srednia))<(fabs(liczba[i-1]-srednia))) boss=liczba[i];
  30. }
  31.  
  32. cout<<boss<<endl;
  33. boss=0;
  34. suma=0;
  35. srednia=0;
  36. wpisanych=0;
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 15240KB
stdin
3
4 1 2 3 4 
4 4 3 2 1
4 0 3 2 4
stdout
2
3
2