只得了四十分,求各位大佬指教
查看原帖
只得了四十分,求各位大佬指教
593001
Langrange2021楼主2021/11/5 16:11
#include <stdio.h>
double average(int m)
{
	int store[20];
	int count,max,min,i,sum=0;
	double ave;
	scanf("%d", &store[0]);
	max = store[0];
	min = store[0];
	for (count = 1; count <= m - 1; count++)
	{
		scanf("%d", &store[count]);
		if (store[count] > max)
		{
			max = store[count];
		}
		if (store[count] < min)
		{
			min = store[count];
		}
	}
	for(i=0;i<=m-1;i++)
	{
		sum += store[i];
	}
	sum -= (max + min);
	ave = sum / (m - 2);
	return ave;

}
int main()
{
	int n, m,count;
	double max;
	scanf("%d%d", &n, &m);
	max = average(m);
	for (count = 2; count <= n; count++)
	{
		if (average(m) > max)
		{
			max = average(m);
		}

	}
	printf("%.2lf", max);
	return 0;
}

以上是我的代码,我只得了40分,不知道出了什么问题,各位大佬能给我指出错误来吗?

2021/11/5 16:11
加载中...