1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <stdio.h>
#define number 12266
#define number2 4074
#define number3 16
#define number4 10
char
trans[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
main()
{
printf("%d base 10 in base 16 is:\n",number);
conv(number);
printf("\n");
printf("%d base 10 in base 16 is:\n",number2);
conv(number2);
printf("\n");
printf("%d base 10 in base 16 is:\n",number3);
conv(number3);
printf("\n");
printf("%d base 10 in base 16 is:\n",number4);
conv(number4);
printf("\n");
}
conv(n)
int n;
{
if (n > 0)
{
if ((n / 16) > 0)
conv(n/16);
printf(" %c ",trans[n%16]);
system("PAUSE");
}
}
|