Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <cstdlib>
- #include <ctime>
- #include <conio.h>
- using namespace std;
- int main()
- {
- srand(time(NULL));
- double x;
- cout<<"Program REFLEKS!\n\n";
- int n=0;
- int f=1;
- double wyniki[n];
- cout<<"Wcisnij ENTER gdy na ekranie pojawi sie 'XD'\n";
- while (f==1 && n<3) //3 to liczba wynikow przed podsumowaniem
- {
- f=0;
- for (int i=0; i<3; i++) Sleep(1000);
- cout<<"Uwaga!\n";
- x=rand()%499+1;
- //timer liczacy czas pokazania sie tekstu
- double sek=0;
- for (int i=1;i<=x;i++)
- {
- Sleep(10);
- if( kbhit() )
- if( getch() == 13 )
- {
- f=1;
- cout<<"Za wczesnie! Spaliles te probe!\n\n";
- break;
- }
- if (i==x) cout<<"XD\n";
- }
- //timer liczacy czas reakcji
- sek=0;
- if (f!=1)
- {
- for (;;)
- {
- sek=sek+0.01;
- Sleep(10);
- if( kbhit() )
- if( getch() == 13 ) break;
- }
- cout<<"Czas reakcji: "<<sek<<".\n\n";
- f=1;
- n++;
- wyniki[n-1]=sek;
- }
- }
- double min=10;
- double suma;
- for (int a=0; a<n; a++)
- {
- suma=suma+wyniki[a];
- if (wyniki[a]<min) min=wyniki[a];
- }
- double srednia=suma/n;
- cout<<"Podsumowanie...\nNajlepszy wynik: "<<min<<endl<<"Sredni wynik: "<<srednia<<endl;
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement