Created
July 18, 2019 12:37
-
-
Save glowing713/78ade54d3354a202c6a278ca61eac72e to your computer and use it in GitHub Desktop.
백준 4344번 평균은 넘겠지
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> | |
using namespace std; | |
int main(void){ | |
int arr[1000] = {0,}; | |
int cycle = 0, snum = 0, sum = 0, avg = 0; | |
cin >> cycle; | |
for(int i = 0; i < cycle; ++i){ | |
cin >> snum; | |
for(int j = 0; j < snum; ++j){ | |
cin >> arr[j]; | |
} | |
for(int k = 0; k < snum; ++k){ | |
sum += arr[k]; | |
} | |
avg = sum/snum; | |
int cnt = 0; | |
for(int l = 0; l < snum; ++l){ | |
if(arr[l] > avg) ++cnt; | |
} | |
/* 이렇게도 가능하다. | |
cout.precision(3); | |
cout << (double)cnt/snum*100 << "%" << endl; | |
*/ | |
printf("%.3f%%\n", (double)cnt/snum*100); | |
sum = 0; | |
avg = 0; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment