1080.cpp

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

CPP
32
字号
/*  This Code is Submitted by wywcgs for Problem 1080 on 2005-03-05 at 18:32:08 */ 
#include <stdio.h>

int main()
{
    int root, i, j, a[11];
    
    while(1){
        root = 0;
        for(i = 0; i < 11; i++){
            a[i] = 0;
        }    
        while((a[0] = getchar()) != '\n'){
            a[0] -= '0';
            root += a[0];
            if(root == 0){
                return 0;
            }    
        }
        while(root >= 10){
            for(i = 0; root >= 10; i++, root /= 10){
                a[i] = root % 10;
            }
            for(j = 0; j < i; j++){
                root += a[j];
            }
        }
        printf("%ld\n", root);
    }

    return 0;
}

⌨️ 快捷键说明

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