Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. char hex2[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  7. unsigned int test=0;
  8. int pos=0;
  9. while(scanf("%d",&test)){
  10. unsigned int temp=test;
  11. char hex[8]={0};
  12. while(temp>0){
  13. int remain=0;
  14. remain=temp & 15;
  15. printf("%d\n",remain);
  16. temp=temp>>4;
  17. hex[pos]=hex2[remain];
  18. pos++;
  19. }
  20. for(int prin=7;prin>=0;prin--){
  21. printf("%s",&hex[prin]);
  22. }
  23. }
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement