摘要:
给定一个数,得到这个数的数位上的数字的平方和,然后循环,如果最后能等于1,则输出true,否则为false. 难点:不知道这个数到底要循环多少轮才能得到1.思路:设置一个最大的循环数(如:20轮),如果达到最大循环次数,还不等于1,则返回false. #include<iostream> #incl 阅读全文
posted @ 2020-05-10 23:33
星海寻梦233
阅读(98)
评论(0)
推荐(0)
摘要:
#include<iostream> #include<vector> #include<algorithm> using namespace std; int rob(vector<int>& nums) { if (nums.size() == 0) return 0; if (nums.siz 阅读全文
posted @ 2020-05-10 22:43
星海寻梦233
阅读(131)
评论(0)
推荐(0)
摘要:
#include<iostream> #include<string> using namespace std; int hammingWeight(uint32_t n) { int ans = 0; while (n) { if (n % 2 == 1) { ans += 1; } n = n 阅读全文
posted @ 2020-05-10 20:12
星海寻梦233
阅读(113)
评论(0)
推荐(0)
摘要:
#include<iostream> #include<string> using namespace std; uint32_t reverseBits(uint32_t n) { uint32_t a = 0; int count = 0; string s = ""; while (n) { 阅读全文
posted @ 2020-05-10 19:47
星海寻梦233
阅读(91)
评论(0)
推荐(0)
浙公网安备 33010602011771号