fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. // zdefiniuj funkcjÄ™
  6. string na2(int liczba) {
  7. if (liczba == 0)
  8. return "0";
  9. string pom = "";
  10. while (liczba > 0) {
  11. pom = char(liczba % 2 + 48) + pom;
  12. liczba = liczba / 2;
  13.  
  14. }
  15. return pom;
  16. }
  17. int main() {
  18. cout<< na2(42)<< endl;
  19. cout<< na2(53)<< endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
1
2
10
42
11
stdout
101010
110101