Uva 591--- Box of Bricks
- #include <iostream>
- using namespace std;
- int main()
- {
- int iStack;
- int iHight[101];
- int iSum, iTime, iTemp;
- int i,j;
- j = 0;
- while (cin >> iStack)
- {
- if ( iStack == 0 )
- break;
- iHight[101] = {0};
- iSum = iTime = 0;
- for ( i=0 ; i<iStack ; i++ )
- {
- cin >> iHight[i];
- iSum += iHight[i];
- }
- iSum = iSum / iStack; // average hight;
- for ( i=0 ; i<iStack; i++ )
- {
- if ( iHight[i] > iSum )
- iTime = iTime + iHight[i] - iSum;
- }
- j++;
- cout << "Set #" << j <<endl;
- cout << "The minimum number of moves is " << iTime << "." <<endl;
- cout << endl;
- }
- }
Uva 591
留言
張貼留言