郭老师的音弟 @ 2021-12-25 16:05:44
#include<iostream>
#include<iomanip>
using namespace std;
int n;
double* a = new double[n];
double minn = 10;
double maxx = 0;
double sum =0;
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
sum += a[i];
if (minn > a[i])
{
minn = a[i];
}
if (maxx < a[i])
{
maxx = a[i];
}
}
double p = sum - minn - maxx;
int m = n - 2;
cout << fixed << setprecision(2) << p / m;
}
by Liweiang @ 2021-12-25 16:09:54
帮你改了一下
#include<iostream>
#include<iomanip>
using namespace std;
int n;
double a [1009];
double minn = 10;
double maxx = 0;
double sum =0;
int main()
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
sum += a[i];
if (minn > a[i])
{
minn = a[i];
}
if (maxx < a[i])
{
maxx = a[i];
}
}
double p = sum - minn - maxx;
double m = n - 2;
cout << fixed << setprecision(2) << p / m;
}
by 郭老师的音弟 @ 2021-12-25 16:53:59
@liweiang09 谢谢宁!