Am I wrong?I think it's right!


  • 0
    7
    static int kk =0;
    
    bool isHappy(int n) {
    
    if(30 ==kk)return false;
    kk++;
    int num1[10]={0 },i,j,k=1;
    for(i=0 ; n/k!= 0 ;i++)
    {
        
        num1[i] = n/k%10;
        k*=10;
         printf("%d\n",num1[i]);
    }
    n=0;
    for(j=0;j<i;j++)
    {
        n+=num1[j]*num1[j];
    }
     printf("%d\n",n);
    if (n ==1)return true;
    else
     return isHappy(n); 
     }

  • 0

    I can't understand the meaning of kk in here.


Log in to reply
 

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