提示: 作者被禁止或删除 内容自动屏蔽
提示: 作者被禁止或删除 内容自动屏蔽
/*楼主代码的简化(未经细致验证)*/
#include<stdio.h>
unsigned short getbits(unsigned short value,int n1,int n2)
{
return(value&0xffff>>n1)>>16-n2;
}
main()
{
unsigned short a;
int n1,n2;
printf("input an number ");
scanf("%o",&a);
printf("input n1 and n2 ");
scanf("%d%d",&n1,&n2);
printf("output:%o\n",getbits(a,n1-1,n2));
}