rev='made'/> name='keywords'/> name='author'/> ANURANAN: UVa Solution 591:Box of Bricks

Welcome Note

Hi,
I'm Anisuzzaman Babla . I am a full stack Android Application Developer. I am working with Android for more than two years. I have completed my graduation from IIT, Jahangirnagar University. I have developed a series of commercially successful apps on Android. Moreover, 10+ of my Apps are live at Google play store. .
Thank You

UVa Solution 591:Box of Bricks

#include<stdio.h>
int main()
{
int n,h[102],i,j,sum,avg,move,set=0;
while(scanf(“%d”,&n)==1)
             {
         if(n==0) break;
         set++;
         sum=0;
         move=0;
                        for(i=0;i<n;i++)
                      {
                      scanf(“%d”,&h[i]);
                      sum+=h[i];
                      }
                            avg=sum/n;
                             for(j=0;j<n;j++)
                            {
                             if (avg<h[j]) move+=h[j]-avg;
                             }
printf(“Set #%d\nThe minimum number of moves is %d.\n\n”,set,move);
                }
return 0;
}

2 comments:

  1. printf(“Set #%d\nThe minimum number of moves is %d.\n\n”,set,move);
    why 2 new line(\n\n) at end..??

    ReplyDelete
    Replies
    1. Please follow this link

      http://i.imgur.com/ofhC6TG.png

      Delete