杭电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')
        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\n",sum);
        i=0;
        while((c=getchar())!='\n')
            N[i++]=c;
    }
    return 0;
}

上一篇:ampify shader工具学习一


下一篇:Linux安装JDK(rpm)