fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main(void) {
  9. int C = 0;
  10. int N = 0;
  11. cin >> C;
  12. for(int i=0; i<C; i++) {
  13.  
  14. cin >> N;
  15.  
  16. int student[N] = {0, };
  17.  
  18. int count = 0;
  19. double score = 0, score_total=0;
  20.  
  21. for(int i=0; i<N; i++) {
  22. cin >> student[i];
  23. }
  24.  
  25. for(int i=0; i<N; i++) {
  26. score_total += student[i];
  27. }
  28. score = score_total/N;
  29.  
  30. for(int i=0; i<N; i++) {
  31. if(student[i] > score) {
  32. count++;
  33. }
  34. }
  35. score = ((double)count/N)*100;
  36. cout.setf(ios::showpoint);
  37. cout.precision(5);
  38. cout << round(score*1000)/1000 << "%" << endl;
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0s 4264KB
stdin
Standard input is empty
stdout
Standard output is empty