1599.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 31 行

CPP
31
字号
/*  This Code is Submitted by wywcgs for Problem 1599 on 2005-03-22 at 08:19:52 */ 
#include <stdio.h>

int main()
{
    int n, h[101], average, step, total;
    int i, j;
    
    for(j = 1; scanf("%d", &n) == 1; j++){
        if(n == 0){
            return 0;
        }else{
            total = 0;
            step = 0;
            for(i = 0; i < n; i++){
                scanf("%d", &h[i]);
                total += h[i];
            }
            average = total / n;
            for(i = 0; i < n; i++){
                if(h[i] < average){
                    step += average - h[i];
                }
            }
            printf("Set #%d\n", j);
            printf("The minimum number of moves is %d.\n\n", step);
        }
    }
    
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?