UVA 591 - Box of Bricks

Problem PDF

Solution:

#include
int main()
{
int n,i,a[100],t=1,sum,c;
while(scanf("%d",&n)==1 && n!=0)
{
  sum=0;
  c=0;
    for(i=0;isum)
    c=c+(a[i]-sum);
    printf("Set #%d\nThe minimum number of moves is %d.\n\n",t++,c);
}
return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/591/591.cpp