C a little long


  • 0
    B

    int a[100];
    unsigned long addDights(unsigned long num)
    {
    int n=0,sum=0;
    LOOP:for(;num>=1;n++)
    {
    a[n]=num%10;
    num/=10;
    sum+=a[n];
    if(num==0&&sum>=10)
    {
    num=sum;
    sum=0;
    }
    }
    if(sum>=10)
    {
    goto LOOP;
    }
    return sum;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.