Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <time.h>
- using namespace std;
- int main() {
- int num,num_1,suma,respuesta;
- int acumulador1=0;
- int ano1=0, ano2=0, res=0,cont=0, contador=0;
- struct tm * fecha_hora;
- time_t segundos;
- segundos = time(NULL);
- fecha_hora=localtime(&segundos);
- ano1=fecha_hora->tm_sec;
- fecha_hora=localtime(&segundos);
- ano2=fecha_hora->tm_sec;
- res=ano2-ano1;
- do{
- num=(rand()%100);
- num_1=(rand()%10);
- suma=num+num_1;
- do{
- segundos=time(NULL);
- fecha_hora=localtime(&segundos);
- ano2=fecha_hora->tm_sec;
- res=ano2-ano1;
- srand(time(NULL));
- cout<<"sus puntos son:"<<acumulador1<<endl;
- cout<<"tiempo transcurrido "<<res<<endl;
- cout<<"ingrese la respuesta de "<<num<<" + "<<num_1<<endl;
- cin>>respuesta;
- if(respuesta==suma){
- cout<<"respuesta correcta"<<endl;
- acumulador1=acumulador1+1000;
- cont++;
- system("pause");
- system("cls");
- }
- else {
- cout<<"respuesta incorrecta.reingrese"<<endl;
- acumulador1=acumulador1-1000;
- contador++;
- system("pause");
- system("cls");
- }
- }
- while(respuesta!=suma);
- }
- while(cont!=10);
- cout<<"juego finalizado(gracias por utilizarlo)"<<endl;
- cout<<"resutado final:"<<endl;
- cout<<" *Tiempo total empleado:(MS) "<<res*1000<<endl;
- cout<<" *Respuestas correctas: "<<cont<<endl;
- cout<<" *Veces no acertadas : "<<contador<<endl;
- cout<<" *Puntos totales : "<<acumulador1<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement