Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int sys2to10 (int n)
- { if (n == 0) return 0;
- else return sys2to10(n/10) * 2 + (n % 10); }
- int sys10to2 (int n)
- { if (n == 0) return 0;
- else return sys10to2(n/2) * 10 + (n % 2) ; }
- int main()
- {
- for (int i = 0; i <= 127; ++i)
- {
- int x = sys10to2(i);
- cout << x << '\t' << sys2to10(x) << '\n';
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment