0分求助
查看原帖
0分求助
649435
Struggle_ong楼主2022/5/9 18:48
#include<iostream>
using namespace std;
int a[100][20],b[100];
double sing(int x[],int y);
double sing(int x[],int y)
{
	int lo=11,hi=-1;
	double t=0;
	for(int i=0;i<y;i++)
	{
		if(x[i]<lo)
		{
			lo=x[i];
		}
		if(x[i]>hi)
		{
			hi=x[i];
		}
	}
	for(int i=0;i<y;i++)
	{
		if(x[i]!=hi&&x[i]!=lo)
		{
			t+=x[i];
		}
	}
	t/=(y-2);
	return t;
}
int main()
{
	int c,d;
	double high=-1,t;
	cin>>c>>d;
	for(int i=0;i<c;i++)
	{
		for(int j=0;j<d;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=0;i<c;i++)
	{
		t=sing(a[i],d);
		if(t<high)
		{
			high=t;
		}
	}
	printf("%.2lf",high);
	return 0;
}
2022/5/9 18:48
加载中...