建议使用结构体
by wky_wsy @ 2024-09-22 11:59:35
@[lihongyi0822](/user/1088791) 你叫什么名字?感觉认识你
by chensiyu2011 @ 2024-09-22 12:02:14
```cpp
#include<bits/stdc++.h>
using namespace std;
int main()
{
int st,ju,maxn=0,ju1[1001],minn=101;
double sum[1001],big;
cin >> st >> ju;
for(int i=0;i<st;i++)
{
for(int j=0;j<ju;j++)
{
cin >> ju1[j];
sum[i]+=ju1[j];
if(ju1[j]>maxn)maxn=ju1[j];
if(ju1[j]<minn)minn=ju1[j];
}
sum[i]=(sum[i]-maxn-minn)/(ju-2); //此处
if(sum[i]>sum[i-1])
big=sum[i];
else
continue;
maxn=0,minn=101;
}
printf("%.2lf",big);
return 0;
}
```
我注释的地方有问题,C++默认整数除以整数会向下取整,所以在这个表达式前面要加上1.0* ,即sum[i]=1.0*(sum[i]-maxn-minn)/(ju-2)
by chensiyu2011 @ 2024-09-22 12:04:25
@[lihongyi0822](/user/1088791)
你好,希望能回复 @[lihongyi0822](/user/1088791)
by kebi_manba24 @ 2024-09-22 12:24:06
ggdttdtdtdtdtdtdtdtdtdtdtdtdtdtttdttdtdtdddtdtdtdtdttdtdtdttdtdtdtdtdtdtdtdttddttdt
by kebi_manba24 @ 2024-09-22 12:25:13
@[lihongyi0822](/user/1088791) hi你知道我是谁
by lzy190609 @ 2024-09-22 13:18:50
@chensiyu2011,改过了,还是全WA。
by lihongyi0822 @ 2024-09-26 16:33:46
```c
#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));
}
```
@[lihongyi0822](/user/1088791)
by sunjunyi1017 @ 2024-10-06 15:39:31
谢谢,已关!
by lihongyi0822 @ 2024-10-07 18:08:18