求解。。。。。。。。。。
[size=12px][size=11px]Alice's Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
This term Alice and Bob has one course named "C programming".This class Mr Lee told them that the unsigned int in C language is a 32-bit integer. That means a unsigned int stored in memory occupied 32 bits. For example, 2147483648(231) stored in memory as 10000000000000000000000000000000, and 4294967295(232-1) stored in memory as 11111111111111111111111111111111.After Alice heard that, She stopped play his iphone 4s and was lost in thought: "What's the number If I take the first 16-bit to the behind of the last 16-bit? " Unfortunately, the number was so large that Alice was unable to calculate... So she had to turn to you. Could you help her to calculate it?
Intput
The input contains multiple test cases (No more than 100).Each case contains a line with a unsigned number.
Output
You should output one line with the correct number Alice wanted to known.
Sample Input
0
41
32768
Sample Output
0
2686976
2147483648[/size]
Hint
32768[sub](10)[/sub] = 1000000000000000[sub](2)[/sub]
2147483648[sub](10)[/sub] = 100000000000000000000000000000000[sub](2)[/sub]
[解决办法]
int left=0x0000ffff,nRes = 0,right=0xffff0000,k=0;
std::cin>>nRes;
left &= nRes;
right &= nRes;
while(k<16)
{
k++;
left = left<<1;
right = right>>1;
}
nRes = left|right;
[解决办法]
//使用库类型bitset,很简单!
#include<iostream>
#include<bitset>
using namespace std;
int main()
{
unsigned int us ;
while(cin>>us)
{
bitset<32> bt(us);
for(unsigned int i=0;i<16;i++)
{
bool temp;
temp = bt[i];
bt[i] = bt[i+16];
bt[i+16] = temp;
}
cout<<bt.to_ulong()<<endl;
}
}