Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///binary conversion using recursion
- #include<bits/stdc++.h>
- using namespace std;
- void bin(int n)
- {
- if(n<=0) return;
- bin(n/2);
- printf("%d",n%2);
- }
- int main()
- {
- int x;
- while(scanf("%d",&x)!=EOF)
- {
- if(x==0)
- {
- printf("0\n");
- continue;
- }
- bin(x);
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement