-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cpp
60 lines (38 loc) · 831 Bytes
/
Program.cpp
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
53
54
55
56
57
58
59
60
void Program()
{
int N(0), M(0), L(0), K(0);
int *array = 0;
int m;
cout << "Enter number of elements ( N ): " << endl;
cin >> N;
cout << "Enter number of steps ( M ): " << endl;
cin >> M;
cout << "Enter number of first step ( K ): " << endl;
cin >> K;
cout << "Enter number of replay steps ( L ): " << endl;
cin >> L;
array = ( int * )malloc( N * sizeof( int ) );
if( array == NULL )
{
cout << "Warning!!! The memory was not allocated. Restart application." << endl;
}
else
{
m = K;
for(int i = 0; i != N; ++i)
{
array[i] = i+1;
}
Preview(array, N);
for(int i = 0 ; i != L; ++i)
{
m=(m + M) % N;
Shift(array, N, m);
Preview(array, N);
}
cout << "Human which was in the end of list: "<< array[N-1] <<endl;
free(array);
}
cin.get();
cin.get();
}