include iostream include time include conio using namespace std int ma

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <time.h>
#include <conio.h>
using namespace std;
int main()
{
setlocale(0,"Rus");
srand(static_cast<unsigned int>(time(0)));
char Char;
do{
int Time, Fall;
cout << "ms = "; cin >> Time;
cout << "Спад = "; cin >> Fall;
int a(clock()/Time),b(a - 1),c(0),d(0);
while(1)
{
if(a == b + 1)
{
system("cls");
cout << "a = " << c << endl;
if(rand() % 3 == 0) c--;
else c++;
if(c > d)d = c;
if(c == d - Fall)
{
system("cls");
cout << "Был спад!!" << endl;
cout << "a = " << c << endl;
cout << "max a = " << d << endl;
break;
}
a += 1;}
b = clock()/Time;
}
cout << "q - exit";
Char = _getch();
system("cls");
}while(Char != 'q');
return 0;
}