修改目录结构,优化CMakeLists
This commit is contained in:
32
src/202.c
Normal file
32
src/202.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
int bitSquareSum(int n)
|
||||
{
|
||||
int sum = 0;
|
||||
while (n > 0)
|
||||
{
|
||||
int bit = n % 10;
|
||||
sum += bit * bit;
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
bool isHappy(int n)
|
||||
{
|
||||
int slow = n, fast = n;
|
||||
do
|
||||
{
|
||||
slow = bitSquareSum(slow);
|
||||
fast = bitSquareSum(fast);
|
||||
fast = bitSquareSum(fast);
|
||||
} while (slow != fast);
|
||||
|
||||
return slow == 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user