Advertisement
STANAANDREY

pb19 13/1/2020

Jan 13th, 2020
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int n;
  5. float a[1000];
  6.  
  7. void read_array(int n)
  8. {
  9.     for (int i = 0; i < n; i++)
  10.         cin >> a[i];
  11. }
  12.  
  13. float get_average(int n, float a[])
  14. {
  15.     float average = 0.0;
  16.     for (int i = 0; i < n; i++)
  17.         average += a[i];
  18.  
  19.     average /= (float) n;
  20.     return average;
  21. }
  22.  
  23. int Count(int n, float a[])
  24. {
  25.     float average = get_average(n, a);
  26.     int k = 0;
  27.     for (int i = 0; i < n; i++)
  28.         if (average <= a[i])
  29.             k++;
  30.     return k;
  31. }
  32.  
  33. int main()
  34. {
  35.     cin >> n;
  36.     read_array(n);
  37.     cout << Count(n, a);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement