力争用复杂的方法做,但是错了

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

qp
by Liu_Yiting_1220 @ 2024-09-26 20:30:54


@[Kuangxirui](/user/855779) ```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:37:45


@[Kuangxirui](/user/855779) 方法二 ```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; } ```
by guoyanwei120223 @ 2024-10-06 15:38:12


``` #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)); } ``` @[Kuangxirui](/user/855779)
by sunjunyi1017 @ 2024-10-06 15:39:03


|