uva 10370 Above Average

NO IMAGE
1 Star2 Stars3 Stars4 Stars5 Stars 給文章打分!
Loading...

Problem

uva 10370 英文題目
沒什麼好說的就是算平均數

#include <iostream>
#include <cmath>
using namespace std;
int main(){
int testcase;
while(cin >> testcase){
int length;
for(int i = 0 ; i < testcase ; i  ){
cin >> length;
double sum = 0;
double *scores = new double[length];
int count = 0;
for(int j = 0 ; j < length ; j  ){
cin >> scores[j];
sum = sum   scores[j];
}
double avg = sum / length;
for(int j = 0 ; j < length ; j  ){
if(scores[j] > avg){
count  ;
}
}
printf("%.3f%%\n",count * 100.0 / length);
}
}
}

相關文章

程式語言 最新文章