解题思路:
注意事项:
参考代码:
#include <stdio.h>
#include <stdlib.h>
unsigned move(unsigned value,int n){
if(n < 0){
n = abs(n);
while(n){
if((value&0x80000000) == 0x80000000)
value = (value<<1)|1;
else
value <<= 1;
n--;
}
}
if(n > 0){
n = abs(n);
while(n){
if((value&1) == 1)
value = (value>>1)|0x80000000;
else
value >>= 1;
n--;
}
}
return value;
}
int main(){
unsigned value;
int n;
scanf("%u %d", &value,&n);
printf("%u\n", move(value,n));
return 0;
}
0.0分
0 人评分