Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void print_base_2(int num);
- int main()
- {
- int x;
- scanf("%d",&x);
- if(!x)printf("0-0");
- else print_base_2(x);
- return 0;
- }
- void print_base_2(int num)
- {
- if (num == 0)
- {
- printf("-");
- return ;
- }
- printf("%d", num % 2);
- print_base_2(num / 2);
- printf("%d", num % 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement