/*
* 解题思路:
* 此题不难,求完平均后再做一下处理
*/
#include <math.h>
#include <stdio.h>
int main( )
{
int n,total = 1;
int i;
int sum1,sum2;
int a[ 55 ];
while( scanf("%d",&n) && n )
{
sum1 = sum2 = 0;
for( i=0;i<n;i++ )
{
scanf("%d",&a[ i ] );
sum1 += a[ i ];
}
sum1 /= n;
for( i=0;i<n;i++ )
sum2 += abs( a[ i ] - sum1 );
printf("Set #%d\n",total++);
printf("The minimum number of moves is %d.\n\n",sum2/=2 );
}
return 0;
}
原文:http://blog.csdn.net/u011886588/article/details/19114297