20分!!!

P5738 【深基7.例4】歌唱比赛

```cpp #include <iostream> using namespace std; int a[101][101],n,m,sum,littlemax,littlemin; double maxans; int main() { cin>>n>>m; for (int i=0;i<n;++i){ for (int j=0;j<m;++j){ cin>>a[i][j]; } } for (int i=0;i<n;++i){ sum=0; littlemax=0; littlemin=11; for (int j=0;j<m;++j){ sum+=a[i][j]; littlemax=max(a[i][j],littlemax); littlemin=min(a[i][j],littlemin); } sum-=littlemax; sum-=littlemin; double abv=sum/double(m-2); maxans=max(abv,maxans); } printf("%.2f",maxans); return 0; } ```
by yuechenxi130407 @ 2024-10-06 10:09:44


```cpp #include<bits/stdc++.h> using namespace std; int main() { int n,m; double MAX=INT_MIN; cin>>n>>m; for(int i=1;i<=n;i++) { double tmp[10001],sum=0; for(int j=1;j<=m;j++) { cin>>tmp[j]; sum+=tmp[j]; } sort(tmp+1,tmp+m+1); sum=sum-tmp[1]-tmp[m]; sum/=(m-2); if(sum>MAX) MAX=sum; } cout<<fixed<<setprecision(2)<<MAX; return 0; } ``` 求关
by jiangyeleii @ 2024-10-06 10:11:04


感谢大佬,AC了,已关
by daishuohua @ 2024-10-06 10:23:48


@[daishuohua](/user/872197) ```cpp #include<iostream> #include<cmath> int a[21],n,m; using namespace std; double pjz() { double z=0; int maxn=0,minn=11; for(int i=1;i<=m;i++) { int f; cin>>f; z+=f; maxn=max(f,maxn); minn=min(f,minn); } z-=maxn; z-=minn; return z; } int main() { double maxa=0; cin>>n>>m; for(int i=1;i<=n;i++) { maxa=max(pjz(),maxa); } printf("%.2lf",(double)maxa/(m-2)); return 0; } ``` AC 求关
by guoyanwei120223 @ 2024-10-06 15:21:06


@[daishuohua](/user/872197) 这样写应该也可以 ```cpp #include<bits/stdc++.h> using namespace std; int a[25]; int maxb=0; void start(int a[],int m) { int sum=0,minn=11,maxn=0; for(int j=1;j<m;j++) { sum+=a[j]; minn=min(a[j],minn); maxn=max(a[j],maxn); } maxb=max(sum,maxb); } int main() { int n,m; cin>>n>>m; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cin>>a[j]; } start(a,m); } printf("%.2lf",(double)maxb/(m-2)); return 0; } ```
by guoyanwei120223 @ 2024-10-06 15:34:39


@[daishuohua](/user/872197) ------------ _~~求关~~_ _
by guoyanwei120223 @ 2024-10-06 15:36:51


@[daishuohua](/user/872197) ``` #include<iostream> using namespace std; int a[30],n,m; int sum=0,maxx=0,minn=10; int x=0; void stat(int a[],int &m){ sum=0,maxx=0,minn=10; for(int j=0;j<m;j++){ if(maxx<a[j])maxx=a[j]; if(minn>a[j])minn=a[j]; sum+=a[j]; } sum-=minn; sum-=maxx; if(x<sum)x=sum; } int main( ) { cin>>n>>m; for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cin>>a[j]; stat(a,m); } printf("%.2lf",(double)x/(m-2)); } @[daishuohua](/user/872197) ```
by sunjunyi1017 @ 2024-10-06 15:37:41


???已经AC了
by daishuohua @ 2024-10-07 11:20:14


|