Advertisement
Georgiy1108

Untitled

Sep 20th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int INF = (int)1e9;
  6.  
  7. int i, k, n;
  8. double mn = INF, s = 0;
  9.  
  10. main()
  11. {
  12.     cin >> n;
  13.     int a[n + 1];
  14.     for(int i = 1; i <= n; i++)
  15.         cin >> a[i];
  16.     for(int i = 1; i <= n; i++)
  17.         s += a[i];
  18.     for(int i = 1; i <= n; i++)
  19.         if(mn > abs(a[i] - (s / n)))
  20.             mn = abs(a[i] - (s / n)), k = i;
  21.     cout << k;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement