Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int liczba=0;
  9.     int dlugosc=0;
  10.     int reszty[dlugosc];
  11.  
  12.     cout << "Podaj liczbê do zamiany: ";
  13.     cin >> liczba;
  14.  
  15.     int pomocnicza=liczba;
  16.  
  17.     for (int i=0; i<=liczba;  i++)
  18.     {
  19.         if (pomocnicza<1)
  20.         {
  21.             break;
  22.         }
  23.         reszty[i]=(pomocnicza%2);
  24.         pomocnicza=(pomocnicza/2);
  25.         dlugosc++;
  26.     }
  27.     for (int z=(dlugosc-1); z>=0; z--)
  28.     {
  29.        cout << reszty[z];
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement