fork download
  1. #include<iostream>
  2. #include<cmath>
  3.  
  4. using namespace std;
  5.  
  6. int liczba_testow;
  7. int tab[101];
  8. float tab2[101];
  9.  
  10. int main()
  11. {
  12. cin >> liczba_testow;
  13.  
  14. while (liczba_testow)
  15. {
  16. int dlugosc;
  17. float suma = 0;
  18. float srednia;
  19. float bufor;
  20. float naj;
  21.  
  22. cin >> dlugosc;
  23.  
  24. for (int i = 0; i < dlugosc; i++)
  25. {
  26. cin >> tab[i];
  27. suma += tab[i];
  28. }
  29. srednia = suma / dlugosc;
  30.  
  31. for (int i = 0; i < dlugosc; i++)
  32. {
  33. tab2[i] = abs(tab[i] - srednia);
  34.  
  35. if (i == 0)
  36. {
  37. bufor = tab2[i];
  38. naj = tab[i];
  39. }
  40.  
  41. else
  42. {
  43. if (tab2[i] < bufor)
  44. {
  45. bufor = tab2[i];
  46. naj = tab[i];
  47. }
  48.  
  49. }
  50.  
  51. }
  52.  
  53. cout << naj << endl;
  54.  
  55. liczba_testow--;
  56. }
  57.  
  58. system("pause");
  59. return 0;
  60. }
  61.  
Success #stdin #stdout #stderr 0s 4512KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
sh: 1: pause: not found