当前位置: 代码迷 >> 综合 >> UVA 160 Factors and Factorials
  详细解决方案

UVA 160 Factors and Factorials

热度:6   发布时间:2024-01-09 02:13:37.0

又是大水题,照着做就行了


#include <stdio.h>double readline()
{int count;scanf("%d", &count);int num[1000] = { 0 };int i = 0;for (int b = 0; b < count; b++){scanf("%d", &num[i]); i++;}double avg = 0; int sum = 0;for (int j = 0; j < i; j++){sum += num[j];}avg = sum*1.0 / i;int above = 0;for (int j = 0; j < i; j++){if (num[j]>avg)above++;}return above*1.0 / count * 100;
}int main()
{int round;scanf("%d", &round);double result[1000];for (int a = 0; a < round; a++){result[a]=readline();if(a<round-1) scanf("\n");}for (int a = 0; a < round; a++){printf("%.3lf%%\n", result[a]);}return 0;
}