Code:
#include <stdio.h>CharHextochar (unsignedintnum) { Switch(num) { Case 0 : return '0'; Case 1 : return '1'; Case 2 : return '2'; Case 3 : return '3'; Case 4 : return '4'; Case 5 : return '5'; Case 6 : return '6'; Case 7 : return '7'; Case 8 : return '8'; Case 9 : return '9'; Case Ten : return 'a'; Case One : return 'b'; Case A : return 'C'; Case - : return 'D'; Case - : return 'e'; Case the : return 'F'; } return '0';}voidMyhex (unsignedintnum) {unsignedintTMP = num% -; if(num > ) myhex (num / +); printf ("%c", Hextochar (TMP));} intMain () {intA =100111; scanf ("%d",&a); Myhex (a); printf ("\ n"); return 0;}
The highlight is the key to this code's use of recursion: 1 recursion to have important exit conditions 2 the parameters of the external parameters in the recursion, after a series of operations, the data is set to the internal parameters, is a major feature.
Run:
Recursively converts a 10 binary number to 16 binary