在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
#include <iostream> #include <assert.h> /** * Key: * * get someone bit: num & (mode1bit<<N) * * check a few bits: num & (mode3bit<<shift) == What */ int replace(int num) { unsigned int mode3bit = 7; unsigned int mode1bit = 1; int shift = 0; int result = 0; while (shift < 32) { while (shift < 32 && (num & (mode3bit<<shift)) != (1<<shift)) { result += (num & (mode1bit<<shift)); shift++; } if (shift >= 32) { break; } else if (32 - shift < 3) { result += (num & (mode3bit<<shift)); break; } result += (3<<shift); shift += 3; } return result; }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论