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