第1个回答 2009-10-27
我也发一个自编的,已验证通过。
#include <stdio.h>
main()
{
char binOut[17];
short int i, j; /* 16bit的整数,要用short int型 */
scanf("%d", &i);
for(j=15;j>=0;j--)
{
if(i&(1<<j))
binOut[15-j] = '1';
else
binOut[15-j] = '0';
}
binOut[16] = 0;
printf("DEC(%d)=BIN(%s)\n",i,binOut);
}本回答被提问者采纳
第2个回答 2009-10-27
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int n;
char a[50];
int main(void)
{
scanf("%d",&n);
itoa(n,a,2);
puts(a);
return 0;
}