Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/07/2011, 14:52
Avatar de baker1562
baker1562
 
Fecha de Ingreso: marzo-2011
Ubicación: Puntarenas
Mensajes: 261
Antigüedad: 13 años, 2 meses
Puntos: 9
Respuesta: Problema con while!!!

despues de postear esto encontre la solucion que era

Código C++:
Ver original
  1. //Programa para Multiplicar usando numero aleatorios de 1 al 10
  2. //Ejercicio 3.55
  3.  
  4. #include <iostream>          
  5. #include <ctime>
  6. #include <cstdlib>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. int numero1;                
  13. int numero2;                
  14. int total;                  
  15. int producto;              
  16. string respuesta;          
  17.  
  18. srand(time(NULL));          
  19.  
  20. numero1=(1+rand()%10);      
  21. numero2=(1+rand()%10);      
  22.  
  23. while(respuesta!="n" && respuesta!="N")              
  24. {
  25.    producto=0;                        
  26.    total=1;                              
  27.    srand(time(NULL));                    
  28.    numero1=(1+rand()%10);                
  29.    numero2=(1+rand()%10);                
  30.    
  31.    while(total!=producto)    
  32.    {
  33.    
  34. cout<<"Cuanto es "<<numero1<<" por "<<numero2<<" ?"<<endl;          
  35. cin>>total;
  36. producto=numero1*numero2;                                        
  37.  
  38.       if(total==producto)
  39.        {
  40.          cout<<"Muy bien! Excelente!!!"<<endl;                    
  41.          cout<<endl;
  42.          cout<<"La multiplicacion es igual a: "<<producto<<endl;
  43.          cout<<endl;
  44.            }
  45.             else
  46.              {                                            
  47.                     cout<<"No.Intenta de nuevo!!"<<endl;    
  48.                     system("pause");
  49.                     system("cls");
  50.                     }
  51.                     }
  52.          cout<<"Desea realizar otra multiplicacion: s/n?"<<endl;    
  53.          cin>>respuesta;
  54.          system("cls");
  55.          }        
  56. return 0;
  57.  
  58. }