Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. void print_base_2(int num);
  3. int main()
  4. {
  5. int x;
  6. scanf("%d",&x);
  7. if(!x)printf("0-0");
  8. else print_base_2(x);
  9. return 0;
  10. }
  11. void print_base_2(int num)
  12. {
  13.  
  14. if (num == 0)
  15. {
  16. printf("-");
  17. return ;
  18. }
  19. printf("%d", num % 2);
  20. print_base_2(num / 2);
  21. printf("%d", num % 2);
  22.  
  23.  
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement