Creative Commons License Foxbond's Repo

/** (c) 2015 Michał (Foxbond) Chraniuk */
#include <stdio.h>
char help[] = {'A', 'B', 'C', 'D', 'E', 'F'};


int dec2hex (int n){
		if (n <=0){
		 		return;
		 }
		 
		 int r = n % 16;
		 dec2hex(n/16);
		 
		 if (r<10){
		 	  printf("%d", r);	
		 }else{
		 		printf("%c", r+55);	 
		 }
		 /*
		 if (r<10){
		 	  printf("%d", r);	
		 }else{
		 		printf("%c", help[r-10]);	 
		 }
		 */
		 
}


int main (){
		int n;
		do {
			 printf("Podaj n (wieksze od 0): ");
		   scanf("%d", &n);
	  }while(n<0);
		printf("Postac hex: ");
		dec2hex(n);
		getch();
		return 0;
}

> Back