#include <stdio.h>
unsigned short moveleft(unsigned short ,int);
unsigned short moveright(unsigned short,int);
int main(int argc, char *argv[])
{
unsigned short a;
int n;
printf("input an octal number:");
scanf("%o",&a);
printf("input n:");
scanf("%d",&n);
if (n > 0)
{
printf("result:%o\n",moveright(a,n));
}
else
{
n = -n;
printf("result:%o\n",moveleft(a,n));
}
system("pause");
}
unsigned short moveleft(unsigned short value,int n)
{
unsigned short z;
z = (value >> (16 - n)) | (value << n);
return z;
}
unsigned short moveright(unsigned short value ,int n)
{
unsigned short z;
z = (value >> n) | (value << (16 - n));
return z;
}
|