Commit 91ca67ff authored by Michael's avatar Michael

michael.davityan:exercise_07_33v4

parent 8e5a5a6e
progname=exercise_07_33
CC=g++
CFLAGS=-g3
CFLAGS=-Wall -Wextra -Werror -g3
all: test1 test2
all: test1 test2
debug/$(progname): debug/$(progname).o
$(CC) $(CFLAGS) $< -o $@
......@@ -23,7 +23,7 @@ clean:
rm -r debug Tests/*.out
test%: debug/$(progname)
@./debug/$(progname) test < Tests/$@.in > Tests/$@.out 2>&1 || echo "$@ is executing..."
@./debug/$(progname) < Tests/$@.in > Tests/$@.out 2>&1 || echo "$@ is executing..."
@diff Tests/$@.out Tests/$@.expected && echo PASSED || echo FAILED
.PRECIOUS: debug/%.ii debug/%.s
......
element value
1 184
2 87
3 178
4 116
5 194
6 136
7 187
8 93
9 50
10 22
11 163
12 28
13 91
14 60
15 164
16 127
17 141
18 27
19 173
20 137
21 12
22 169
23 168
24 30
25 183
26 131
27 63
28 124
29 68
30 136
31 130
32 3
33 23
34 59
35 70
36 168
37 194
38 57
39 12
40 43
41 30
42 174
43 22
44 120
45 185
46 138
47 199
48 125
49 116
50 171
51 14
52 127
53 92
54 181
55 157
56 74
57 63
58 171
59 197
60 82
61 106
62 126
63 85
64 128
65 137
66 106
67 47
68 130
69 114
70 58
71 125
72 96
73 183
74 146
75 15
76 168
77 35
78 165
79 44
80 151
81 88
82 9
83 77
84 179
85 189
86 185
87 4
88 52
89 155
90 200
91 133
92 61
93 77
94 169
95 140
96 13
97 27
98 187
99 95
100 140
Found value in element 83
184
87
178
116
194
136
187
93
50
22
163
28
91
60
164
127
141
27
173
137
12
169
168
30
183
131
63
124
68
136
130
3
23
59
70
168
194
57
12
43
30
174
22
120
185
138
199
125
116
171
14
127
92
181
157
74
63
171
197
82
106
126
85
128
137
106
47
130
114
58
125
96
183
146
15
168
35
165
44
151
88
9
77
179
189
185
4
52
155
200
133
61
77
169
140
13
27
187
95
140
77
element value
1 184
2 87
3 178
4 116
5 194
6 136
7 187
8 93
9 50
10 22
11 163
12 28
13 91
14 60
15 164
16 127
17 141
18 27
19 173
20 137
21 12
22 169
23 168
24 30
25 183
26 131
27 63
28 124
29 68
30 136
31 130
32 3
33 23
34 59
35 70
36 168
37 194
38 57
39 12
40 43
41 30
42 174
43 22
44 120
45 185
46 138
47 199
48 125
49 116
50 171
51 14
52 127
53 92
54 181
55 157
56 74
57 63
58 171
59 197
60 82
61 106
62 126
63 85
64 128
65 137
66 106
67 47
68 130
69 114
70 58
71 125
72 96
73 183
74 146
75 15
76 168
77 35
78 165
79 44
80 151
81 88
82 9
83 77
84 179
85 189
86 185
87 4
88 52
89 155
90 200
91 133
92 61
93 77
94 169
95 140
96 13
97 27
98 187
99 95
100 140
Value not found
100
184
87
178
116
194
136
187
93
50
22
163
28
91
60
164
127
141
27
173
137
12
169
168
30
183
131
63
124
68
136
130
3
23
59
70
168
194
57
12
43
30
174
22
120
185
138
199
125
116
171
14
127
92
181
157
74
63
171
197
82
106
126
85
128
137
106
47
130
114
58
125
96
183
146
15
168
35
165
44
151
88
9
77
179
189
185
4
52
155
200
133
61
77
169
140
13
27
187
95
140
111
......@@ -2,7 +2,6 @@
#include <iomanip>
#include <unistd.h>
#include <cstdlib>
#include <ctime>
int
recursiveLinearSearch(const int integersArray[], const size_t sizeOfArray, const int searchKey,
......@@ -18,17 +17,18 @@ recursiveLinearSearch(const int integersArray[], const size_t sizeOfArray, const
}
int
main(int argc, char **argv)
main()
{
if (1 == argc) {
std::srand(std::time(0));
}
const size_t ARRAY_SIZE = 100;
int integersArray[ARRAY_SIZE] ;
std::cout << "element\t" << std::setw(8) << "value" << std::endl;
int integersArray[ARRAY_SIZE];
if (::isatty(STDIN_FILENO)) {
std::cout << "Insert array elements\n";
}
for (size_t index = 0; index < ARRAY_SIZE; ++index) {
integersArray[index] = 1 + rand() % 200;
std::cout << index + 1 << "\t" << std::setw(6) << integersArray[index] << std::endl;
if (::isatty(STDIN_FILENO)) {
std::cout << "element "<< index + 1 << ": ";
}
std::cin >> integersArray[index];
}
if (::isatty(STDIN_FILENO)) {
std::cout << "Enter integer search key: ";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment