40分求助大佬QAQ只有#1,#4过了 跪谢

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

@[EZ4_H0r1z0n](/user/725130) 给你改好了 code: ------------ ```cpp #include<bits/stdc++.h> #include<cmath> using namespace std; int main() { int n=0,m=0; cin>>n>>m; double score[m+1],se[n+1],tmp=0; for(int i=0;i<n;i++){ for(int o=0;o<m;o++){ cin>>score[o]; } sort(score,score+m); for(int p=1;p<m-1;p++){ tmp+=score[p]; } se[i]=tmp/(m-2); tmp=0; } sort(se,se+n); printf("%.2lf",se[n-1]); } ```
by shalu @ 2023-08-12 16:53:44


@[shalu](/user/920861) 跪谢大佬QAQ
by EZ4_H0r1z0n @ 2023-08-12 16:54:37


@[EZ4_H0r1z0n](/user/725130) 给个关注吧
by shalu @ 2023-08-12 16:54:39


@[EZ4_H0r1z0n](/user/725130) 你稍等,我给你找些材料,我看你的sort好像不太懂
by shalu @ 2023-08-12 16:55:13


@[EZ4_H0r1z0n](/user/725130) sort默认是升序,结构体或者降序要写cmp函数 code: ------------ ```cpp #include<bits/stdc++.h> using namespace std; bool cmp(int x,int y){//升序 return x<y; } bool cmp(int x,int y){//降序 return x>y; } int main(){ //另附sort的公式: //sort(数组的名称加起始下标(是0则不写,否则写为数组名+...的形式),数组的名称加排序元素的个数的后一个元素,(cmp)); return 0; } ```
by shalu @ 2023-08-12 17:01:03


@[EZ4_H0r1z0n](/user/725130) https://blog.csdn.net/VariatioZbw/article/details/125155432
by shalu @ 2023-08-12 17:01:24


@[shalu](/user/920861) 好人一生平安
by EZ4_H0r1z0n @ 2023-08-12 17:03:00


|