Last active
June 20, 2020 05:40
-
-
Save 2hanX/193118cfcfab442047e69c605ab6ed15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<array> | |
using namespace std; | |
const int SIZE = 10; | |
int main() | |
{ | |
array<double, SIZE> donation; | |
double sum = 0.0; | |
double average = 0.0; | |
int cnt = 0; | |
int i = 0; | |
while (i<SIZE && cin>>donation[i]) | |
{ | |
sum += donation[i]; | |
i++; | |
} | |
average = sum / i; | |
for (int j = 0; j < i; j++) | |
{ | |
if (donation[j] > average) | |
cnt += 1; | |
} | |
cout << "average: " << average << "\n" << "cnt: " << cnt << endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment