低到高(左到右)
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
using namespace std;
void ok(int n,int _Mask)
{
_Mask = _Mask -1;
int a=1;
a<<=_Mask;
n|=a;
cout<<n<<endl;
}
//5 = 101
//7 = 111
//8 = 1000
//9 = 1001
int _tmain(int argc, _TCHAR* argv[])
{
ok(5,2);
ok(8,1);
system("pause");
return 0;
}