Advertisement
ferseg

Invertir un Numero Recursividad

Sep 12th, 2014
28,652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. /*  Autor: Joel Cesar Fernandez Segura
  2.     Fecha: 28/08/2014
  3.     Tema: Recursividad
  4.     Ejercicio 4: Invertir un numero
  5. */
  6.  
  7. #include<iostream>
  8. #include<cstdlib>
  9. using namespace std;
  10.  
  11. void invertir(int nro){
  12.     cout<<nro%10;
  13.     if (nro>10) invertir(nro/10);
  14.  
  15. }
  16. int main( void ){
  17.     system("color 0a");
  18.     int nro;
  19.     cout<<"\n\t\t[     RECURSIVIDAD     ]\n";
  20.     cout<<"\t\t------------------------\n\n";
  21.     cout<<" EJERCICIO 4: Invertir un numero "<<endl<<endl;
  22.     do{
  23.             cout<<" INGRESE NUMERO: ";
  24.             cin>>nro;
  25.             if(nro<0) cout<<"\nINGRESE UN NUMERO ENTERO Y POSITIVO... \n";
  26.     }while(nro<0);
  27.     cout<<"\n NUMERO:"<<nro;
  28.     cout<<"\nINVERTIDO:";
  29.     invertir(nro);
  30.     cout<<endl<<endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement