为什么会输出负值
查看原帖
为什么会输出负值
1267232
limitlessly楼主2024/10/14 21:49

为什么会输出负值

#include<bits/stdc++.h>
using namespace std;
int x,n,sum,mx,mn=15;
int main(){
	scanf("%d",&n);
	while(n--){
		scanf("%d",&x);
		sum+=x;
		mx=max(mx,x);
		mn=min(mn,x);
	}
	printf("%.2f",1.0*(sum-mx-mn)/(n-2));
	return 0;
}

程序的输出与答案绝对值一致,但正负性不相同

2024/10/14 21:49
加载中...