Advertisement
thesonpb

đổi cơ số trong hệ đếm

Mar 30th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     long a;
  10.     cin >> a;
  11.     a=abs(a);
  12.     int s[1000];
  13.     int i=0;
  14.     do{
  15.         s[i]=a%2;
  16.         i++;
  17.         a/=2;
  18.     }
  19.     while(a!=0);
  20.     for(int j=i-1; j>=0; j--){
  21.         cout<<s[j];
  22.     }
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement