Đây là đoạn mã đổi từ số có mã Hex ( mã 16) ra mã Bin (mã Nhị phân)
[codes=c]#include 
#include 
void main() 
  { 
    int num; 
     unsigned int mask; 
     // clrscr(); 
      printf ("Chuong trinh doi so hexa sang nhi phan\n"); 
      printf ("Nhap vao so hexa :"); 
      scanf("%x",&num); 
      mask = 0x8000; 
      printf("\n Dang nhi phan cua so %x la ",num); 
      for (int j=1; j<=16; j++) 
        { 
          printf("%d",mask & num?1:0); 
          if (j==4 || j==8 || j==12) printf("-"); 
          mask >>=1; 
      } 
      getch(); 
  } [/codes]
2 responses to “Source code chuyển mã Hex ra Bin”
[emot]shuai[/emot][emot]shuai[/emot][emot]shuai[/emot][emot]shuai[/emot][emot]shuai[/emot][emot]shuai[/emot]
[emot]uplook[/emot]