简易的10进制整数进制转换程序,要求支持2进制

#include
#include
int main()
{
int i,j;
int a[10];
int num;

scanf("%d",&num);

int b1=num;
for(i=0;b1!=0;i++)
{
    a[i]=b1%2;
    b1=b1/2;
}
for(j=i;j>=0;j--)
    {
        printf("%d",a[j]);
    }

return 0;
}

#include <stdio.h>

typedef struct Consequence{
int num;
Consequence *next;

};

int main(){

Consequence *first = new Consequence();
Consequence *a = new Consequence();
first->next = NULL;


int m = 1000;
int n = 16;

while(m){
    Consequence *now = new Consequence();
    now->next  = first->next;
    first->next = now;
    now->num  = m%n;
    m = m/n;
}

a = first->next;
while(a){
    if((a->num)<10 && (a->num)>=0)
        printf("%d",a->num);
    if((a->num)>=10 && (a->num)<16)
        printf("%c",(a->num)-10+'A');
    a = a->next;
}

return 0;
}