求助
查看原帖
求助
1388829
MSCopilot楼主2024/7/17 11:43

为什么不对

#include <iostream>
using namespace std;

int lst[1000];

int main()
{
	int n, highest = 0, lowest = 10, tmp, highdel = 0, lowdel = 0;
	double rslt;
	cin >> n;
	for (int i; i < n; i++)
	{
		cin >> tmp;
		if (tmp > highest)
		{
			highest = tmp;
		}
		if (tmp < lowest)
		{
			lowest = tmp;
		}
		lst[i] = tmp;
	}
	for (int i; i < n; i++)
	{
		if (lst[i] == highest && highdel == 0)
		{
			highdel = 1;
			continue;
		}
		if (lst[i] == lowest && lowdel == 0)
		{
			lowdel = 1;
			continue;
		}
		rslt += lst[i];
	}
	rslt /= 1.0 * n - 2;
	cout << rslt << endl;
	return 0;
}

2024/7/17 11:43
加载中...