MeehoweCK

Untitled

Oct 4th, 2020
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void dec_to_bin(int liczba, int system)
  6. {
  7.     int i=0,tab[31];
  8.  
  9.     while(liczba)
  10.     {
  11.         tab[i++]=liczba%system;
  12.         liczba/=system;
  13.     }
  14.  
  15.     for(int j=i-1; j>=0; j--)
  16.     {
  17.         if(tab[j] > 9)
  18.             cout << static_cast<char>(tab[j] + 55);
  19.         else
  20.             cout << tab[j];
  21.     }
  22. }
  23.  
  24. int main()
  25. {
  26.     dec_to_bin(198745, 2);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment