• 杭电1013-Digitai Root(另解)


    #include<stdio.h>
    #define maxsize 1000

    int main(){
        char N[maxsize+1];
        int i,j,sum,n;
        char c;

        i=0;
        while((c=getchar())!=' ')
            N[i++]=c;
        while(N[0]!='0'){
            sum=0;
            for(j=0;j<i;j++)
                sum+=N[j]-'0';
            while(sum){
                if(sum<10)
                    break;
                else{
                    n=sum;
                    sum=0;
                    while(n){
                        sum+=n%10;
                        n/=10;
                    }
                }
            }
            printf("%d ",sum);
            i=0;
            while((c=getchar())!=' ')
                N[i++]=c;
        }
        return 0;
    }

  • 相关阅读:
    jQuery
    jQuery
    jQuery
    jQuery
    jQuery 遍历- 过滤:缩小搜索元素的范围
    jQuery 遍历
    jQuery 遍历
    jQuery 遍历
    jQuery 遍历:jQuery 遍历 什么是遍历?
    jQuery 尺寸:处理元素和浏览器窗口的尺寸
  • 原文地址:https://www.cnblogs.com/wft1990/p/4324152.html
Copyright © 2020-2023  润新知