#include <stdio.h>
double scores(double arr[][20], int y, int m)//数组,某行,评委人数
{
double min = arr[0][0];
double max = arr[0][0];
double sum = 0;
for (int i = 0; i < m; i++)
{
if (max < arr[y][i])
{
max = arr[y][i];
}
if (min > arr[y][i])
{
min = arr[y][i];
}
}
for (int i = 0; i < m; i++)
{
sum = sum + arr[y][i];
}
double result = (sum - max - min) / ((m - 2) * 1.0);
return result ;
}
int main()
{
int n = 0;
int m = 0;
double arr[100][20] = { 0 };
double score[100] = { 0 };
double max = 0;
scanf("%d %d", &n, &m);
for(int i=0;i<n;i++)
for (int j = 0; j < m; j++)
{
scanf("%lf", &arr[i][j]);
}
for (int i = 0; i < n; i++)
{
score[i] = scores(arr, i, m);
}
for (int i = 0; i < n; i++)
{
if (score[i] > max)
{
max = score[i];
}
}
printf("%.2lf", max);
return 0;
}
求大佬帮忙看看,第二个测试点错了,正确输出是7.39,我的输出是7.44,我好像数据类型都用的double,不知道为什么精度还是不够。