document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*  Autor: Joel Cesar Fernandez Segura
  2.     Fecha: 28/08/2014
  3.     Tema: Recursividad
  4.     Ejercicio 3: Calcular la potencia de n
  5. */
  6.  
  7. #include<iostream>
  8. #include<cstdlib>
  9. using namespace std;
  10.  
  11. long int potencia(int base,int e){
  12.     if(e==0) return 1;
  13.     if(e==1) return base;
  14.     else return base*potencia(base,e-1);
  15. }
  16. int main( void ){
  17.     system("color 0a");
  18.     int b,e;
  19.     cout<<"\\n\\t\\t[     RECURSIVIDAD     ]\\n";
  20.     cout<<"\\t\\t------------------------\\n\\n";
  21.     cout<<" EJERCICIO 2: Calcular la Potencia de n "<<endl<<endl;
  22.     cout<<" INGRESE BASE: ";
  23.     cin>>b;
  24.  
  25.     do{
  26.             cout<<" INGRESE EXPONENTE: ";
  27.             cin>>e;
  28.             if(e<0) cout<<"\\nINGRESE UN NUMERO ENTERO Y POSITIVO... \\n";
  29.     }while(e<0);
  30.     cout<<endl;
  31.     cout<<"\\n Base:"<<b;
  32.     cout<<"\\n Exp:"<<e;
  33.     cout<<"\\n\\n RESULTADO: "<<potencia(b,e)<<endl<<endl;
  34.  
  35.     return 0;
  36. }
');