sweet_520 @ 2024-10-15 08:40:52
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int n;
cin >> n;
double arr[301] = {0};
double sum1 = 0;
double av1;
int m1=-1, m2=-1;
for (int i = 0; i < n; i++)
{
cin >> arr[i];
sum1 = sum1 + arr[i];
}
av1 = sum1 / n;
double max = 0;
double min = arr[0];
for (int i = 0; i < n; i++)
{
if (arr[i] > max)
{
max = arr[i];
m1 = i;
}
}
for (int i = 0; i < n; i++)
{
if (arr[i] <min)
{
min = arr[i];
m2 = i;
}
}
double cha=0;
for (int i = 0; i < n; i++)
{
if (i!=m1&&i!=m2)
{
if (fabs(arr[i] - av1) > cha)
{
cha = fabs(arr[i] - av1);
}
}
}
cout << fixed << setprecision(2) << av1;
cout << " " << fixed << setprecision(2) << cha << endl;
return 0;
}
by liupinli2012_mini @ 2024-10-15 11:44:52
@sweet_520 在?
by liupinli2012_mini @ 2024-10-15 11:45:14
lz还在吗?
by sweet_520 @ 2024-10-15 14:01:54
@liupinli2012_mini 怎么关注你的大号,我不会
by liupinli2012_mini @ 2024-10-15 18:58:53
https://www.luogu.com.cn/user/838514
n(e)wcz祭