#include<stdio.h>

#include<stdlib.h>

int num[1000] = {0};

int len = 0;

int exist(int n){

for(int i = 0;i < len;i++)

if(num[i] == n)

return 1;

num[len] = n;

len ++;

return 0;

}

bool isHappy(int n) {

int result = 0;

if(n == 0)

return false;

```
while(1){
while(n>0){
result = result+(n%10)*(n%10);
n = n/10;
}
if(result == 1)
return true;
else if(exist(result))
return false;
else {
n = result;
result = 0;
}
}
```

}