提交时间:2023-12-23 12:38:56
运行 ID: 34521
#include<bits/stdc++.h> using namespace std; typedef struct node{ int t; int cou; } node a[1010]; int cmp(node a,node b){ return a.t<b.t; } int main() { int n; int every=0; double avg; int sum=0; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i].t); a[i].cou=i+1; } sort(a,a+n,cmp); for(int i=0;i<n;i++){ if(i==n-1){ printf("%d\n",a[i].cou); }else{ printf("%d ",a[i].cou); } if(i!=0){ every+=a[i-1].t; } sum+=every; } avg=sum*1.0/n; printf("%.2f",avg); return 0; }