joj1863
2011-08-29 09:00
302 查看
1863: Above Average
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 1081 | 602 | Standard |
The first line of standard input contains an integer C, the number of test cases. C data sets follow. Each data set begins with an integer, N, the number of people in the class (1 <= N <= 1000). N integers follow, separated by spaces or newlines, each giving
the final grade (an integer between 0 and 100) of a student in the class. For each case you are to output a line giving the percentage of students whose grade is above average, rounded to 3 decimal places.
Sample Input
5 5 50 50 70 80 100 7 100 95 90 80 70 60 50 3 70 90 80 3 70 90 81 9 100 99 98 97 96 95 94 93 91
Output for Sample Input
40.000% 57.143% 33.333% 66.667% 55.556%
Submit /
Problem List / Status /
Discuss
Problem Set with Online Judge System Version 3.12
Jilin University
Developed by skywind,
SIYEE
#include<cstdio>
int average(int p[],int n)
{
int sum=0;
for(int i=0;i<n;i++)sum+=p[i];
return sum/n;
}
int main()
{
int n;
int m;
int a[10000];
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&m);
for(int j=0;j<m;j++)
{
scanf("%d",&a[j]);
}
int ave=average(a,m);
int count=0;
for(int j=0;j<m;j++)
{
if(a[j]>ave)++count;
}
printf("%.3f",100*(float)count/m);
printf("%c\n",'%');
}
return 0;
}
相关文章推荐
- joj 儿死三八
- JOJ 2200 Fracions
- JOJ 1060: Time And Motion 解题报告
- JOJ 1182: Lotto
- JOJ 2650: 礼物
- hdoj1863
- joj 2284 W-LINE
- joj 1019解题报告
- joj 2330: Math
- joj 1002: Stockbroker Grapevine(最短路floyd)
- joj 1509Hamiltonian Cycle (dfs求H回路)
- joj 1509
- joj2484
- joj 2662: 采购方案
- joj2645
- JOJ 1240 The Decoder
- joj 1171
- JOJ1483:Exponentiation
- joj1277
- HDU 1863 畅通工程