#include
int num[100];
int main()
{
int n,t=0,i;
scanf("%d",&n);
while(n)
{
num[t++] = (n & 1);
n >>= 1;
}
for(i=t-1;i>=0;i--)
printf("%d",num[i]);
puts("");
return 0;
}
#include
const char *dec2bin(int value)
{
static char res[65];
char *ptr = res + 64;
*ptr = 0;
while (value) {
*(--ptr) = (value & 0x01) + '0';
value >>= 1;
}
printf("%s\n", ptr);
return ptr;
}
int main()
{
dec2bin(10);
dec2bin(16);
dec2bin(9);
return 0;
}
#include
#include
void main(void)
{
int number;
char string[25];
printf("请输入一个十进制数:");
scanf("%d",&number);
itoa(number, string, 2);
printf("二进制为%s\n", string);
}