简单题
class Solution {
public:
bool isHappy(int n) {
set<int> s;
while(true){
int num = 0;
while(n != 0){
num = num + pow(n % 10, 2);
n = n / 10;
}
if(num == 1) return true;
if(s.find(num) != s.end()){
break;
}else{
s.insert(num);
n = num;
}
}
return false;
}
};