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