fork(12) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int funcao(int n, int pot, int bin) {
  5.  
  6. bin += (n % 2)* pot;
  7. n = n/2;
  8. pot = pot *10;
  9.  
  10. if (n <= 0) {
  11. return bin;
  12. }
  13. bin = funcao(n, pot, bin);
  14. }
  15.  
  16. int main() {
  17. int n,pot,bin;
  18.  
  19. cout << endl << " Digite o Numero: ";
  20. cin >> n;
  21. pot = 1;
  22. bin = 0;
  23. bin = funcao(n, pot, bin);
  24. //while (n > 0){
  25. // bin += (n % 2)* pot;
  26. // pot *= 10;
  27. // n = n/2;
  28. //}
  29. cout << " " << "Result: " << bin;
  30. cin.get();
  31. return 0;
  32. }
Success #stdin #stdout 0s 3144KB
stdin
25
stdout
  Digite o Numero:   Result: 11001