fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int liczba;
  8. cout << "Podaj liczbę";
  9. cin >> liczba;
  10. cin.ignore();
  11. int i=0;
  12. int reszta;
  13. string reszta_string;
  14.  
  15. do{
  16. reszta=liczba%2;
  17. // cout << liczba << "\t"<<reszta<<endl;
  18. reszta_string+=std::to_string(reszta);
  19. liczba=liczba/2;
  20. i++;
  21. }
  22. while(reszta<=liczba);
  23.  
  24. cout << reszta_string;
  25. cout << "koniec";
  26. }
Success #stdin #stdout 0s 3432KB
stdin
15
stdout
Podaj liczbę1111koniec