标签:
static List<int> nums = new List<int>();
public static bool IsHappy(int n)
{
int newint = 0;
while (n != 0)
{
newint += ((n % 10) * (n % 10));
n = n / 10;
}
if (newint == 1)
return true;
if (nums.Contains(newint))
{
return false;
}
else
{
nums.Add(newint);
}
return IsHappy(newint);
}
LeetCode中Submission Result: Wrong Answer,
LeetCode202:Happy Number 。C#版,在vs2010中通过,leetcode中Wrong Answer
标签:
原文地址:http://www.cnblogs.com/darksied/p/4711607.html