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. return pom;
  15.  
  16. }
  17. int main() {
  18. cout << (na2(42)) << endl;
  19. cout << (na2(53)) << endl;
  20. // sprawdź działanie funkcji
  21. return 0;
  22. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
101010
110101