求补码怎么求的...#include #include void main (){unsigned short int a;unsigned short int getbits(unsigned short);printf ("\ninput an octal number:");scanf ("%o",&a);printf ("%o\n",getbits(a));}unsigned short int getbits (unsigned short value){u

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/05 02:42:06

求补码怎么求的...#include #include void main (){unsigned short int a;unsigned short int getbits(unsigned short);printf ("\ninput an octal number:");scanf ("%o",&a);printf ("%o\n",getbits(a));}unsigned short int getbits (unsigned short value){u
求补码怎么求的...
#include
#include
void main ()
{
unsigned short int a;
unsigned short int getbits(unsigned short);
printf ("\ninput an octal number:");
scanf ("%o",&a);
printf ("%o\n",getbits(a));
}
unsigned short int getbits (unsigned short value)
{
unsigned int short z;
z=value&0100000;
if(z==0100000)
z=~value+1;
else
z=value;
return z;
}
输入152525怎么会输出25253呢?书上的例子,

求补码怎么求的...#include #include void main (){unsigned short int a;unsigned short int getbits(unsigned short);printf ("\ninput an octal number:");scanf ("%o",&a);printf ("%o\n",getbits(a));}unsigned short int getbits (unsigned short value){u
程序让你输入的是8进制数字,所以152525是八进制的
化成二进制为1101 0101 0101 0101
判断第一位是1
z等于 取反+1 = 10 1010 1010 1010 +1 在打印成8进制就是25253了