/*
* : 16
*/
#include <stdio.h>
#include <stdlib.h>
void hex_covert(int x);
void hex_covert(int x)
{
char a;
int y;
if (x==0)
{
printf("0");
return ;
}
y = x%16;
if (y>=10)
a = (y - 10) + 'a';
else
a = y + '0';
x = x/16;
if (x != 0)
hex_covert(x);
printf("%c", a);
}
int main()
{
int x;
printf("
===========Program Start==============
");
printf("Please input a number to covert:");
scanf("%d", &x);
printf("Hex:%x
", x);
printf("Now, let's use a function to covert
");
printf("Hex:");
hex_covert(x);
printf("
");
printf("=============Program End==============
");
return 0;
}