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 4: Calcular el producto de dos numeros
  5. */
  6.  
  7. #include<iostream>
  8. #include<cstdlib>
  9. using namespace std;
  10.  
  11. int producto(int a,int b){
  12.     if(a==0||b==0) return 0;
  13.     if(a==1) return b;
  14.     if(b==1) return a;
  15.     else return a+producto(a,b-1);
  16. }
  17. int main( void ){
  18.     system("color 0a");
  19.     int a,b;
  20.     cout<<"\\n\\t\\t[     RECURSIVIDAD     ]\\n";
  21.     cout<<"\\t\\t------------------------\\n\\n";
  22.     cout<<" EJERCICIO 3: Calcular el Producto de 2 numeros "<<endl<<endl;
  23.     cout<<" INGRESE MULTIPLICANDO: ";
  24.     cin>>a;
  25.     cout<<" INGRESE MULTIPLICADOR: ";
  26.     cin>>b;
  27.  
  28.     cout<<endl;
  29.     cout<<"\\n MDO:"<<a;
  30.     cout<<"\\n MDOR:"<<b;
  31.     cout<<"\\n\\n RESULTADO: "<<producto(a,b)<<endl<<endl;
  32.  
  33.     return 0;
  34. }
');