码迷,mamicode.com
首页 > 其他好文 > 详细

hdu2088

时间:2017-03-19 11:04:43      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:art   sum   scanf   code   分享   ++   font   color   技术   

hdu2088

技术分享
 1 #include<stdio.h>
 2 #include<algorithm>
 3 using namespace std;
 4 int h[55];
 5 int main(){
 6     int N,t=0;
 7     while(scanf("%d",&N)!=EOF&&N!=0){
 8 
 9         int sum=0,q;
10         for(q=1;q<=N;q++){
11             scanf("%d",&h[q]);
12             sum+=h[q];
13         }
14         if(t++){printf("\n");}
15         int ave=sum/N;
16         sort(h+1,h+N+1);
17         int t=0;
18         for(q=N;h[q]>ave;q--)t+=(h[q]-ave);
19         printf("%d\n",t);
20     }
21     return 0;
22 }
View Code

 

hdu2088

标签:art   sum   scanf   code   分享   ++   font   color   技术   

原文地址:http://www.cnblogs.com/cenariusxz/p/6578191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!