C:
set
class Solution
{
public: int getnum(int n) { int sum 0; while(n) { sum (n%10) * (n%10); n/10; } return sum; } bool isHappy(int n) { unordered_set<int> res; while(1) { int sum getnum(n); if(sum 1) return true;
//在C中是用.fi…
饿汉式(线程安全)
public class Singleton {// 直接创建实例,在类加载时就完成实例化private static final Singleton instance new Singleton();// 私有构造函数private Singleton() {}// 提供公共的静态方法获取实例public static Single…