#include <iostream> using namespace std; #define B_SHIFT 4 int getBinBlockSize(int size) { int q = 0; for ( q= 0; size>0; size >>= 1) { q++; } return 1 << q; } static int getBinBlockSize2(int size) { int q; size = size >> B_SHIFT; for (q = 0; size; size >>= 1) { q++; } return (1 << (B_SHIFT + q)); } int _tmain(int argc, _TCHAR* argv[]) { int a; cout << "please input a positive integer:"; cin >> a; cout << getBinBlockSize2(a) << endl; system("PAUSE"); return 0; }
原创文章,作者:306829225,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/268375.html