Advertisement
nguyenhappy92

Đổi một số hệ 10 sang 16

Oct 27th, 2015
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. // Viet chuong trnh chuyen doi he so 10 sang 16
  2. #include<stdio.h>
  3. #include<conio.h>
  4.  
  5. void main()
  6. {
  7. int a[100],n;
  8. int x;
  9. int k=0;
  10. char b[16]={'0','1','2','3','4','5','6','7','8','9','A'
  11. ,'B','C','D','E','F'};
  12. scanf("%d",&n);
  13. while(n>0)
  14. {
  15. k++;
  16. x=n%16;
  17. a[k]=x;
  18. n=n/16;
  19. }
  20. for(int i=k;i>0;i--)
  21. {
  22. printf("%c ",b[a[i]]);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement