Advertisement
Guest User

juego tp 2

a guest
Feb 1st, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <time.h>
  5. using namespace std;
  6.  
  7. int main() {
  8.     int num,num_1,suma,respuesta;
  9.     int acumulador1=0;
  10.     int ano1=0, ano2=0, res=0,cont=0, contador=0;
  11.     struct tm * fecha_hora;
  12.     time_t segundos;
  13.     segundos = time(NULL);
  14.     fecha_hora=localtime(&segundos);
  15.     ano1=fecha_hora->tm_sec;
  16.     fecha_hora=localtime(&segundos);
  17.     ano2=fecha_hora->tm_sec;
  18.     res=ano2-ano1;
  19.    
  20.     do{
  21.    
  22.     num=(rand()%100);
  23.     num_1=(rand()%10);
  24.     suma=num+num_1;
  25.     do{
  26.     segundos=time(NULL);
  27.     fecha_hora=localtime(&segundos);
  28.     ano2=fecha_hora->tm_sec;
  29.     res=ano2-ano1;
  30.     srand(time(NULL));
  31.     cout<<"sus puntos son:"<<acumulador1<<endl;
  32.     cout<<"tiempo transcurrido "<<res<<endl;
  33.     cout<<"ingrese la respuesta de "<<num<<" + "<<num_1<<endl;
  34.     cin>>respuesta;
  35.     if(respuesta==suma){
  36.         cout<<"respuesta correcta"<<endl;
  37.         acumulador1=acumulador1+1000;
  38.         cont++;
  39.         system("pause");
  40.         system("cls");
  41.     }
  42.     else {
  43.         cout<<"respuesta incorrecta.reingrese"<<endl;
  44.         acumulador1=acumulador1-1000;
  45.         contador++;
  46.         system("pause");
  47.         system("cls");
  48.     }
  49.     }
  50.     while(respuesta!=suma);
  51.     }
  52.     while(cont!=10);
  53.     cout<<"juego finalizado(gracias por utilizarlo)"<<endl;
  54.     cout<<"resutado final:"<<endl;
  55.     cout<<"               *Tiempo total  empleado:(MS) "<<res*1000<<endl;
  56.     cout<<"               *Respuestas   correctas:     "<<cont<<endl;
  57.     cout<<"               *Veces no acertadas    :     "<<contador<<endl;
  58.     cout<<"               *Puntos totales        :     "<<acumulador1<<endl;
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement