과연 그럴까요?
cout.precision(3); //부동소수점
cout << fixed; // 소수점 고정
강제형변환 괜찮은가?
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int C;
cin >> C;
for (int i = 0; i < C; i++) {
int N;
cin >> N;
vector<int> v;
int input;
int sum = 0;
for (int j = 0; j < N; j++) {
cin >> input;
v.push_back(input);
sum += input;
}
double avg = (double)sum / (double)N;
int up = 0;
for (int j = 0; j < N; j++) {
if (v[j] > avg)
up++;
}
cout.precision(3);
cout << fixed;
cout << (double)up / (double)N * 100 << "%\n";
}
return 0;
}