#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;
int youyi(int x,double n)
{
double l = sizeof(int)*8;
int r;
r = ( x&( (int)pow(2,(l-n))-1 ) ) * ((int)pow(2,n));
return r;
}
int _tmain(int argc, _TCHAR* argv[])
{
cout<<youyi(1,2)<<endl;
system("pause");
return 0;
}
#include <iostream>
#include <math.h>
using namespace std;
int youyi(int x,double n)
{
double l = sizeof(int)*8;
int r;
r = ( x&( (int)pow(2,(l-n))-1 ) ) * ((int)pow(2,n));
return r;
}
int _tmain(int argc, _TCHAR* argv[])
{
cout<<youyi(1,2)<<endl;
system("pause");
return 0;
}