info@sislbd.com +8801775 012 358

UVA Online Judge – 591 – Box of Bricks

#include <stdio.h>

int main()
{
int number,store[102],i,totalbricks,moves_bricks,set=0,avg;

while(scanf(“%d”, &number) && number)
{
totalbricks=0;
moves_bricks=0;
set +=1;
for(i=0;i<number;i++)
{
scanf(“%d”, &store[i]);
totalbricks += store[i];
} // End of for

avg=totalbricks/number;
for(i=0;i<number;i++)
if(avg > store[i])
moves_bricks +=avg-store[i];

printf(“Set #%d\n”,set);
printf(“The minimum number of moves is %d.\n”,moves_bricks);
printf(“\n”);
} // End of while
} // End of main

spectrum