1.Cè¯è¨ï¼è¾åºè¡¥ç
2.二进制原码补码转换c语言源代码
Cè¯è¨ï¼è¾åºè¡¥ç
æ±è¡¥ç çå½æ°å¯ä»¥åèä¸é¢ç代ç ï¼æ们ç¥éï¼å¨å åä¸ï¼æ£æ°çè¡¥ç çäºä»æ¬èº«ï¼æ以ç´æ¥è¿åaãè´æ°çè¡¥ç æ£æ¯å®å¨å åä¸çåå¨å½¢å¼ï¼è¿æ¯æ们å®ä¹ä¸ä¸ªunsigned intåçæ°å¼å»ç¨å®æ¥èµå¼ï¼åå¾çå°±æ¯ä»çè¡¥ç çäºè¿å¶å½¢å¼ã为äºéªè¯ï¼æå¦å¤ç¼åäºä¸ä¸ªå½æ°ï¼ç¨æ¥è¾åºäºè¿å¶ï¼è¯·åèã
unsigned int buma(int a)//ç¨æ¥æ±å¾è¡¥ç
{
if(a>=0)
return a;
else
{
unsigned int temp=a;
return temp;
}
}
void twoprint(unsigned int a)//ç¨æ¥è¾åºäºè¿å¶
{
int temp=a%2;
if(a/2==0)
{
cout<<a<<" ";return ;
}
twoprint(a/2);//è¿ééç¨äºéå½è°ç¨çæ¹æ³
cout<<temp<<" ";
}
二进制原码补码转换c语言源代码
#include <stdio.h>
int main()
{
char in[],补码c补校园服务小程序源码下载 out[];
scanf("%s", in);
if(strlen(in) < 8 || in[0] == 0) printf("%s\n", in);
else
{
int i;
out[0] = '1' ;
for(i = 1; i < 8; i ++)
{
if(in[i] == '0')
out[i] = '1';
else out[i] = '0';
}
for(i = 7; i >0; i --)
{
if(out[i] == '0')
{
out[i] = '1';
break;
}
else out[i] = '0';
}
out[8] = 0;
printf("%s\n", out);
}
}