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. int main() {
  17. cout<<na2(42)<< endl;
  18. cout<<na2(53)<< endl;
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
101010
110101