Solution of Problem-D- Boxa of Bricks

#include<stdio.h>
int main()
{
int m=0,i,n,a[100];
do
{
int cout=0,av,sum=0;
scanf(“%d”,&n);
if(n==0)
break;
else
{
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
sum+=a[i];
}
av=sum/n;
for(i=0;i<n;i++)
{
if(av<a[i])
{
cout+=(a[i]-av);
}
}
m++;
printf(“Set# %d\nThe minimum number of moves is %d”,m,cout);
}
}while(!feof(stdin));
}

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: