Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/10/2011, 04:23
Avatar de baker1562
baker1562
 
Fecha de Ingreso: marzo-2011
Ubicación: Puntarenas
Mensajes: 261
Antigüedad: 13 años, 1 mes
Puntos: 9
Respuesta: Programa que pide 2 numeros enteros

Código C++:
Ver original
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int division(int a, int b)
  6. {
  7.      if(b>a)
  8.         {
  9.             return 0;
  10.         }
  11.         else
  12.         {
  13.             return division(a-b,b)+1;
  14.         }
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.     int numero1;
  21.     int temp;
  22.     int numero2;
  23.     int residuo;
  24.    
  25.     cout<<"Ingrese el primer digito:"<<endl;
  26.     cin>>numero1;
  27.     cout<<"Ingrese el segundo numero:"<<endl;
  28.     cin>>temp;
  29.     while(temp<0||temp==0)
  30.     {
  31.       cout<<"ERROR-NUMERO ES 0 O MENOR QUE 0!!!"<<endl;
  32.       cout<<"Ingrese el segundo numero:"<<endl;
  33.       cin>>temp;
  34.       }
  35.     numero2=temp;
  36.      
  37.     cout<<"El cociente es:"<<division(numero1,numero2)<<endl;
  38.     cout<<"El residuo es:"<<(numero1-(numero2*division(numero1,numero2)));
  39.    
  40. }