心态崩了,怎么写
查看原帖
心态崩了,怎么写
384074
Oliver00871楼主2020/11/9 20:37
#include<stdio.h>
using namespace std;
double sort(int a[100][20], int m, int n);
void sort1(int x[], int n);
int main()
{
	double m, n;
	int i = 0, j = 0;
	int a[100][20];
	cin >> m >> n;
	while (n--)
	{
		for (i = 1; i < m; i++)
		{
			int q;
			cin >> q;
			a[j][i] = q;
		}
		j++;
	}
	int b[100];
	int e = 0;
	for(int i = 0; i < 100; i++)
	{
		
		b[i] = sort(a,m,n);
		e++;
	
	}
	sort1(b, e);
	cout << b[e];

}
double sort(int a[100][20], int m, int n)//void sort(int a[100][20], int m, int n);
{
	int max, t;
	for (int i = 0; i < m; i++)
	{
		t = i;
		for (int j = i + 1; j < m; j++)
			if (a[n][t] > a[n][j]) t = j;
		if (t != i)
		{
			max = a[n][i];
			a[n][i] = a[n][t];
			a[n][t] = max;
		}
	}
	int i = 1;
	double c = 0;
	for (; i < m - 1; i++)
	{
		c += a[n][i];
	}
	double d = c / (m - 2);
	return d;
}
void sort1(int x[], int n)
{
	int t, min;
	for (int i = 0; i < n; i++)
	{
		t = i;
		for (int j = i + 1; j < n; j++)
			if (x[t] > x[j]) t = j;
		if (t != i)
		{
			min = x[i];
			x[i] = x[t];
			x[t] = min;

		}
	}
}```
2020/11/9 20:37
加载中...