Advertisement
PaweU

Refleks

Jan 3rd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. srand(time(NULL));
  12. double x;
  13.  
  14. cout<<"Program REFLEKS!\n\n";
  15.  
  16. int n=0;
  17. int f=1;
  18. double wyniki[n];
  19.  
  20.  
  21. cout<<"Wcisnij ENTER gdy na ekranie pojawi sie 'XD'\n";
  22.  
  23. while (f==1 && n<3) //3 to liczba wynikow przed podsumowaniem
  24. {
  25. f=0;
  26.  
  27. for (int i=0; i<3; i++) Sleep(1000);
  28. cout<<"Uwaga!\n";
  29.  
  30.  
  31. x=rand()%499+1;
  32.  
  33. //timer liczacy czas pokazania sie tekstu
  34. double sek=0;
  35.  
  36. for (int i=1;i<=x;i++)
  37. {
  38. Sleep(10);
  39.  
  40. if( kbhit() )
  41.              if( getch() == 13 )
  42. {
  43. f=1;
  44. cout<<"Za wczesnie! Spaliles te probe!\n\n";
  45. break;
  46. }
  47.  
  48. if (i==x) cout<<"XD\n";
  49. }
  50.  
  51. //timer liczacy czas reakcji
  52. sek=0;
  53.  
  54. if (f!=1)
  55. {
  56. for (;;)
  57. {
  58. sek=sek+0.01;
  59. Sleep(10);
  60.  
  61.  
  62. if( kbhit() )
  63.              if( getch() == 13 ) break;
  64. }
  65.  
  66. cout<<"Czas reakcji: "<<sek<<".\n\n";
  67. f=1;
  68. n++;
  69. wyniki[n-1]=sek;
  70. }
  71.  
  72. }
  73.  
  74. double min=10;
  75. double suma;
  76. for (int a=0; a<n; a++)
  77. {
  78. suma=suma+wyniki[a];
  79. if (wyniki[a]<min) min=wyniki[a];
  80. }
  81.  
  82. double srednia=suma/n;
  83. cout<<"Podsumowanie...\nNajlepszy wynik: "<<min<<endl<<"Sredni wynik: "<<srednia<<endl;
  84.  
  85. getchar();
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement