Skip to content

Instantly share code, notes, and snippets.

@2hanX
Last active June 20, 2020 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2hanX/193118cfcfab442047e69c605ab6ed15 to your computer and use it in GitHub Desktop.
Save 2hanX/193118cfcfab442047e69c605ab6ed15 to your computer and use it in GitHub Desktop.
#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