Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int liczba,mnoznik=1,liczbaDwa=0;
- //int * tablica=new int[1],ileWTab=1;
- int main()
- {
- cout << "Podaj liczbe - ";
- cin >> liczba;
- //Po 1023 - int sie konczy
- /*
- while(liczba){
- liczbaDwa+=(liczba%2)*mnoznik;
- mnoznik*=10;
- liczba/=2;
- }
- cout << liczbaDwa;
- */
- //Od tylu wypisuje, po 2147483647 psuje sie
- /*
- while(liczba){
- cout << liczba%2;
- liczba/=2;
- }
- */
- //Z tablica dynamiczna
- //Choc nie wiem jak dokladnie dziala
- /*
- while(liczba){
- tablica[ileWTab-1]=liczba%2;
- liczba/=2;
- ileWTab++;
- }
- for(ileWTab;ileWTab>1;ileWTab--)
- cout << tablica[ileWTab-2] << " ";
- delete [] tablica;
- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement