forked from grantrostig/cpp_by_example
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
123 lines (118 loc) · 2.33 KB
/
main.cpp
File metadata and controls
123 lines (118 loc) · 2.33 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <iostream>
using namespace std;
int c(int);
int a(const int a1) {
srand(a1);
int a2 {12};
while (a2%5 != 0 ) {
a2 = rand()%17;
switch (a2) {
case 0:
cout << "0\n";
return 0;
case 11: // DIFFERENT from c()!!
cout << "1\n";
a(a2*2);
return a2*2;
case 2:
cout << "2\n";
b(2);
break;
case 6:
cout << "6\n";
break;
case 8:
cout << "8\n";
continue;
case 16:
cout << "16\n";
c(a2);
break;
case 14:
cout << "14\n";
break;
default:
cout << "other\n";
continue;
}
}
return 3;
}
int b(const int a1) {
srand(a1);
int a2 {12};
while (a2%5 != 0 ) {
a2 = rand()%17;
switch (a2) {
case 0:
cout << "0\n";
return 0;
case 21: // DIFFERENT!!
cout << "1\n";
a(a2*2);
return a2*2;
case 2:
cout << "2\n";
b(2);
break;
case 6:
cout << "6\n";
break;
case 8:
cout << "8\n";
continue;
case 16:
cout << "16\n";
a(a2); // DIFFERENT
break;
case 14:
cout << "14\n";
break;
default:
cout << "other\n";
continue;
}
}
return 3;
}
int c(const int a1) {
srand(a1);
int a2 {12};
while (a2%5 != 0 ) {
a2 = rand()%17;
switch (a2) {
case 0:
cout << "0\n";
return 0;
case 1:
cout << "1\n";
a(a2*2);
return a2*2;
case 2:
cout << "2\n";
b(2);
break;
case 6:
cout << "6\n";
break;
case 8:
cout << "8\n";
continue;
case 16:
cout << "16\n";
c(a2);
break;
case 14:
cout << "14\n";
break;
default:
cout << "other\n";
continue;
}
}
return 3;
}
int main() {
cout << c(42) << endl;
cout << "###" << endl;
}