@[祁恩葛](/user/331557) 你倒数第4行`cout<<endl; `~~你当初是为什么打上去的~~
by linyuhuai @ 2021-05-22 18:54:28
@[祁恩葛](/user/331557) 把倒数第4行`cout<<endl;`删掉就过了
by linyuhuai @ 2021-05-22 18:56:09
问题未解决
?^?
by ISTIA @ 2021-05-22 19:07:31
```cpp
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
double a(int n)
{
int a[1010],c;
for(int s=1;s<=n;s++)
{
cin>>a[s];
}
sort(a+1,a+n+1);
for(int s=2;s<=n-1;s++)
{
c+=a[s];
}
double i=(double)c/(n-2);
return i;
}
int main()
{
int n,m;
double max=-10.000;
cin>>n;
cin>>m;
for(int i=0;i<n;i++)
{
int o=a(m);
if(o>max)
{
max=o;
}
}
cout<<fixed<<setprecision(2)<<max<<endl;
return 0;
}
```
by ISTIA @ 2021-05-22 19:10:24
@[祁恩葛](/user/331557)
后面我看了下,有$2$处错误:
1. 函数里的$c$未归零
2. $o$不是`double`类型
改过且测过可以$AC$的:
```cpp
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;
double a(int n) {
int a[1010],c=0;
for(int s=1; s<=n; s++) {
cin>>a[s];
}
sort(a+1,a+n+1);
for(int s=2; s<=n-1; s++) {
c+=a[s];
}
double i=(double)c/(n-2)*1.000;
return i;
}
int main() {
int n,m;
double max=-10.000;
cin>>n;
cin>>m;
for(int i=0; i<n; i++) {
double o=a(m);
if(o>max) {
max=o;
}
}
printf("%.2lf",max);
return 0;
}
```
by linyuhuai @ 2021-05-22 20:01:04
@[linyuhuai](/user/505244) 谢谢
by ISTIA @ 2021-05-22 20:14:11