91分求助
查看原帖
91分求助
693931
caitou007楼主2022/3/21 12:03

除了给出的样例过不了,其他都可以,我很惊讶```

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double ans=0;
	int a[1024],b[1024];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(a[i]==b[j]){
				cout<<j<<" ";
				for(int k=1;k<i;k++){
					ans+=a[k];
				}
				continue;
			}
		}
	}
	cout<<endl;
	cout<<fixed<<setprecision(2)<<ans/n;
	return 0;
} 
2022/3/21 12:03
加载中...