标签:
10
56 12 1 99 1000 234 33 55 99 812
3 2 7 8 1 4 9 6 10 5
291.90
代码:
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef struct node{ int t; int cou; }; node a[1000]; 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; }
标签:
原文地址:http://www.cnblogs.com/TWS-YIFEI/p/5701556.html