Advertisement
huutho_96

nhị phân

Apr 12th, 2015
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. char a[3] = "01";
  4. int dequy(int n)
  5. {
  6. if (n > 0)
  7. {
  8. dequy(n / 2);
  9. cout << a[n % 2];
  10. }
  11. return n;
  12. }
  13. void nhiphan(int n)
  14. {
  15. int numOfBit = sizeof(n)* 8;
  16. int i;
  17. for (i = numOfBit - 1; i >= 0; --i)
  18. { printf("%d", (n >> i) & 0x01); }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement