Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b7a6253

Browse files
committed
Exercise 26.2
1 parent 126647f commit b7a6253

File tree

6 files changed

+341
-0
lines changed

6 files changed

+341
-0
lines changed

‎Chapter_26/C26_Exercise_26.2.cpp

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
/* Exercise 26.2 */
2+
3+
#include<iostream>
4+
#include<sstream>
5+
#include<fstream>
6+
#include<iomanip>
7+
#include<vector>
8+
#include"C26_Exercise_26.2.h"
9+
10+
using namespace std;
11+
12+
inline void error(string s) { throw runtime_error(s); }
13+
inline void error(const string& s, const string& s2) { error(s + s2); }
14+
inline void error(const string& s, int i) { ostringstream os; os << s << ": " << i; error(os.str()); }
15+
inline void keep_window_open() { char ch; cin >> ch; }
16+
inline int randint(int max) { return rand() % max; }
17+
inline int randint(int min, int max) { return randint(max - min) + min; }
18+
19+
int main()
20+
{
21+
enum Action {
22+
EXIT = -1, PRINTACTIONLIST,
23+
CASE1, CASE2, CASE3, CASE4, CASE5, CASE6, CASE7, CASE8, CASE9, CASE10
24+
};
25+
const string actionList = "\tList of actions:\n"
26+
" (1) BinarySearch()\n"
27+
" (-1) Exit, (0) Print the list of actions\n";
28+
cout << actionList;
29+
int action;
30+
bool cond{ true };
31+
while (cond) try {
32+
cout << "\nPlease enter the action: ";
33+
if (!(cin >> action)) { ClearInput(cin); error("Error. Incorrect input"); }
34+
char ch;
35+
cin.get(ch);
36+
switch (action) {
37+
case CASE1: {
38+
cout << endl;
39+
{
40+
cout << "int:" << endl;
41+
string fileInput{ "C26_Exercise_26.2_test_int.txt" };
42+
ifstream ifs{ fileInput };
43+
if (!ifs) error("Error. Can't open input file: ", fileInput);
44+
cout << sp_2 << "File: " << fileInput << endl;
45+
TestAll<int>(ifs, cout);
46+
47+
// Test 8 "Sets generated using random numbers"
48+
constexpr int numberOfElements = 50;
49+
constexpr int spread = 20;
50+
stringstream ss;
51+
for (int i = 1; i <= 20; ++i) {
52+
vector<int> v;
53+
int sum = 0;
54+
for (int j = 0; j < numberOfElements; ++j) {
55+
sum += randint(spread);
56+
v.push_back(sum);
57+
}
58+
int x = v[randint(v.size())];
59+
ss << "{ 8." << i << " " << x << " { ";
60+
for (int j = 0; j < v.size(); ++j) {
61+
ss << v[j] << " ";
62+
}
63+
ss << "} 1 }" << endl;
64+
}
65+
cout << sp_2 << "Sets generated using random numbers" << endl;
66+
TestAll<int>(ss, cout);
67+
}
68+
69+
{
70+
cout << endl << "double:" << endl;
71+
string fileInput{ "C26_Exercise_26.2_test_double.txt" };
72+
ifstream ifs{ fileInput };
73+
if (!ifs) error("Error. Can't open input file: ", fileInput);
74+
cout << sp_2 << "File: " << fileInput << endl;
75+
TestAll<double>(ifs, cout);
76+
77+
// Test 8 "Sets generated using random numbers"
78+
constexpr int numberOfElements = 50;
79+
constexpr int spread = 20;
80+
stringstream ss;
81+
for (int i = 1; i <= 20; ++i) {
82+
vector<double> v;
83+
double sum = 0;
84+
for (int j = 0; j < numberOfElements; ++j) {
85+
sum += double(randint(spread)) + double(randint(1, 99)) / 100;
86+
v.push_back(sum);
87+
}
88+
double x = v[randint(v.size())];
89+
ss << "{ 8." << i << " " << x << " { ";
90+
for (int j = 0; j < v.size(); ++j) {
91+
ss << v[j] << " ";
92+
}
93+
ss << "} 1 }" << endl;
94+
}
95+
cout << sp_2 << "Sets generated using random numbers" << endl;
96+
TestAll<double>(ss, cout);
97+
}
98+
99+
{
100+
cout << endl << "string:" << endl;
101+
string fileInput{ "C26_Exercise_26.2_test_string.txt" };
102+
ifstream ifs{ fileInput };
103+
if (!ifs) error("Error. Can't open input file: ", fileInput);
104+
cout << sp_2 << "File: " << fileInput << endl;
105+
TestAll<string>(ifs, cout);
106+
107+
// Test 8 "Sets generated using random numbers"
108+
constexpr int numberOfLetters = 'z' - 'a' + 1;
109+
constexpr int maxLetters = 5;
110+
constexpr char firstLetter = 'a';
111+
stringstream ss;
112+
for (int i = 1; i <= 20; ++i) {
113+
vector<string> v;
114+
string s;
115+
for (int j = 0; j < numberOfLetters; ++j) {
116+
s = "";
117+
s += firstLetter + j;
118+
for (int k = 1; k < maxLetters; ++k) {
119+
s += char(randint('a', 'z' + 1));
120+
}
121+
v.push_back(s);
122+
}
123+
string x = v[randint(v.size())];
124+
ss << "{ 8." << i << " " << x << " { ";
125+
for (int j = 0; j < v.size(); ++j) {
126+
ss << v[j] << " ";
127+
}
128+
ss << "} 1 }" << endl;
129+
}
130+
cout << sp_2 << "Sets generated using random numbers" << endl;
131+
TestAll<string>(ss, cout);
132+
}
133+
134+
cout << vsp_2;
135+
break;
136+
}
137+
case PRINTACTIONLIST:
138+
cout << actionList;
139+
break;
140+
case EXIT:
141+
cond = false;
142+
break;
143+
default:
144+
error("Error. Incorrect action number");
145+
break;
146+
}
147+
}
148+
catch (runtime_error& e) {
149+
cerr << e.what() << endl;
150+
}
151+
catch (...) {
152+
cerr << "Error. Exception\n";
153+
return 1;
154+
}
155+
return 0;
156+
}
157+
158+
void ClearInput(istream& is)
159+
{
160+
is.clear();
161+
is.ignore(numeric_limits<streamsize>::max(), '\n');
162+
}
163+
164+
template<class T> istream& operator>>(istream& is, Test<T>& t)
165+
{
166+
/*
167+
format: { N TV { V1 V2 V3 ... } B }
168+
N - <string> test number
169+
TV - <T> target value
170+
V1, V2, V3 ... - <T> sequence of values to search for
171+
B - <bool> ('0' or '1') the expected result of the search
172+
*/
173+
Test<T> test;
174+
// cb - curly brace
175+
constexpr char cbLeft{ '{' };
176+
constexpr char cbRigth{ '}' };
177+
char ch1, ch2;
178+
is >> ch1 >> test.label >> test.val >> ch2;
179+
if (!is) return is;
180+
if (ch1 != cbLeft || ch2 != cbLeft) {
181+
is.setstate(ios::failbit);
182+
return is;
183+
}
184+
while (true) {
185+
char ch3;
186+
is >> ch3;
187+
if (!is) return is;
188+
if (ch3 == cbRigth) break;
189+
is.unget();
190+
T val;
191+
is >> val;
192+
if (!is) return is;
193+
test.seq.push_back(val);
194+
}
195+
is >> test.res;
196+
if (!is) return is;
197+
char ch4;
198+
is >> ch4;
199+
if (!is) return is;
200+
if (ch4 != cbRigth) {
201+
is.setstate(ios::failbit);
202+
return is;
203+
}
204+
t = test;
205+
return is;
206+
}
207+
208+
template<class T> int TestAll(istream& is, ostream& os)
209+
{
210+
int testCount = 0;
211+
int errorCount = 0;
212+
os << boolalpha;
213+
for (Test<T> t; is >> t; ) {
214+
bool r = BinarySearch(t.seq.begin(), t.seq.end(), t.val);
215+
if (r != t.res) {
216+
os << sp_4 << "Failure: test { " << t.label << " }; BinarySearch(): sequence { ";
217+
for (const T& x : t.seq) {
218+
os << x << ' ';
219+
}
220+
os << "} " << t.seq.size() << " elements; Target value { " << t.val
221+
<< " } -> { " << t.res << " }" << endl;
222+
++errorCount;
223+
}
224+
++testCount;
225+
}
226+
if (!is && !is.eof()) os << sp_6 << "Invalid test" << endl;
227+
os << noboolalpha;
228+
os << sp_8 << "Number of tests: " << testCount << endl;
229+
os << sp_8 << "Number of errors: " << errorCount << endl;
230+
return errorCount;
231+
}
232+
233+
template<class RandomAccessIterator, class T>
234+
bool BinarySearch(RandomAccessIterator first, RandomAccessIterator last, const T& x)
235+
{
236+
using Iter = RandomAccessIterator;
237+
if (first == last) return false;
238+
--last;
239+
while (first <= last) {
240+
Iter middle = (last - first) / 2 + first;
241+
if (*middle == x) return true;
242+
else if (*middle > x) last = middle - 1;
243+
else first = middle + 1; // *middle < x
244+
}
245+
return false;
246+
}

‎Chapter_26/C26_Exercise_26.2.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* Exercise 26.2 */
2+
3+
using namespace std;
4+
5+
const char* sp_2 = " ";
6+
const char* sp_4 = " ";
7+
const char* sp_6 = " ";
8+
const char* sp_8 = " ";
9+
const char* vsp_2 = "\n\n";
10+
const char* vsp_3 = "\n\n\n";
11+
const char* vsp_4 = "\n\n\n\n";
12+
13+
void ClearInput(istream& is);
14+
15+
template<class T> struct Test {
16+
string label;
17+
T val;
18+
vector<T> seq;
19+
bool res;
20+
};
21+
22+
template<class T> istream& operator>>(istream& is, Test<T>& t);
23+
24+
template<class T> int TestAll(istream& is, ostream& os);
25+
26+
template<class RandomAccessIterator, class T>
27+
bool BinarySearch(RandomAccessIterator first, RandomAccessIterator last, const T& x);
28+
29+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ 1 15.55 { } 0 }
2+
{ 2.1 15.55 { 2.1 15.55 16.42 } 1 }
3+
{ 2.2 15.55 { -2.98 15.55 } 1 }
4+
{ 2.3 15.55 { 15.55 17.34 30.87 } 1 }
5+
{ 3.1 15.55 { -43.45 -42.78 -39.467 -35.67 -30.4567 -28.657 -26.546 -20.23 -15.67 -14.45 -12.3 -10.0 -8.5 -6.56 -3.67 -1.6 0.0 1.456 3.6 5.67 6.78 8.675 10.67 11.5 15.55 18.45 19.3 22.9 28.456 30.6 34.7 39.67 41.67 49.23 58.67 59.78 61.54 93.678 } 1 }
6+
{ 3.2 15.55 { -434.56 -431.78 -420.567 -410.6 -400.546 -399.56 -390.2 -380.8 -371.67 -340.78 -320.56 -315.78 -309.78 -301.2 -300.78 -290.7 -289.78 -271.5 -270.8 -260.467 -222.45 -211.345 -199.67 -100.3 -43.35 -12.67 -8.67 -4.768 -1.3 0.0 1.356 2.78 4.78 5.67 6.3 8.8 9.3 11.78 15.55 35.67 94.7 124.647 165.78 244.67 564.67 933.67 1145.67 1255.3 1599.78 2222.900 3445.64 9325.67 35553.6 44554.4567 99949.67 134412.56 255355.67 459999.3 699455.467 999999.78 } 1 }
7+
{ 4.1 -1000.11 { -20004553467567 -33344466645 -1000.11 0 543534 324565345345 1999888777234565 } 1 }
8+
{ 4.2 222333444.2 { -10000000008678 -5000007 -100 44444 222333444.2 200000000758679 } 1 }
9+
{ 5.1 61.867 { -43.5 -42.7 -39.6 -35.2 -30.78 -28.678 -26.8 -20.3 -15.4 -14.24 -12.567 -10.7 -8.78 -6.34 -3.4 -1.3 0.0 1.2 3.7 5.6 6.6 8.46 10.89 11.6 15.3 18.34 19.35 22.56 28.36 30.87 34.3 39.76 41.87 49.56 58.8 59.87 61.867 93.87 } 1 }
10+
{ 5.2 -39.6 { -43.5 -42.7 -39.6 -35.2 -30.78 -28.678 -26.8 -20.3 -15.4 -14.24 -12.567 -10.7 -8.78 -6.34 -3.4 -1.3 0.0 1.2 3.7 5.6 6.6 8.46 10.89 11.6 15.3 18.34 19.35 22.56 28.36 30.87 34.3 39.76 41.87 49.56 58.8 59.87 61.867 93.87 } 1 }
11+
{ 5.3 93.87 { -43.5 -42.7 -39.6 -35.2 -30.78 -28.678 -26.8 -20.3 -15.4 -14.24 -12.567 -10.7 -8.78 -6.34 -3.4 -1.3 0.0 1.2 3.7 5.6 6.6 8.46 10.89 11.6 15.3 18.34 19.35 22.56 28.36 30.87 34.3 39.76 41.87 49.56 58.8 59.87 61.867 93.87 } 1 }
12+
{ 5.4 -43.5 { -43.5 -42.7 -39.6 -35.2 -30.78 -28.678 -26.8 -20.3 -15.4 -14.24 -12.567 -10.7 -8.78 -6.34 -3.4 -1.3 0.0 1.2 3.7 5.6 6.6 8.46 10.89 11.6 15.3 18.34 19.35 22.56 28.36 30.87 34.3 39.76 41.87 49.56 58.8 59.87 61.867 93.87 } 1 }
13+
{ 6.1 30.45 { -43.56 -43.56 -39.65 -35.7 -30.56 -28.56 -28.56 -28.56 -15.56 -14.45 -12.6 -10.5 -10.5 -10.5 -10.5 -1.6 0.0 1.1 1.1 5.6 6.3 8.8 8.8 8.8 8.8 8.8 19.6 22.67 28.546 30.45 34.2 34.2 34.2 34.2 58.45 59.6 59.6 93.9 } 1 }
14+
{ 6.2 -43.56 { -43.56 -43.56 -39.65 -35.7 -30.56 -28.56 -28.56 -28.56 -15.56 -14.45 -12.6 -10.5 -10.5 -10.5 -10.5 -1.6 0.0 1.1 1.1 5.6 6.3 8.8 8.8 8.8 8.8 8.8 19.6 22.67 28.546 30.45 34.2 34.2 34.2 34.2 58.45 59.6 59.6 93.9 } 1 }
15+
{ 6.3 8.8 { -43.56 -43.56 -39.65 -35.7 -30.56 -28.56 -28.56 -28.56 -15.56 -14.45 -12.6 -10.5 -10.5 -10.5 -10.5 -1.6 0.0 1.1 1.1 5.6 6.3 8.8 8.8 8.8 8.8 8.8 19.6 22.67 28.546 30.45 34.2 34.2 34.2 34.2 58.45 59.6 59.6 93.9 } 1 }
16+
{ 6.4 59.6 { -43.56 -43.56 -39.65 -35.7 -30.56 -28.56 -28.56 -28.56 -15.56 -14.45 -12.6 -10.5 -10.5 -10.5 -10.5 -1.6 0.0 1.1 1.1 5.6 6.3 8.8 8.8 8.8 8.8 8.8 19.6 22.67 28.546 30.45 34.2 34.2 34.2 34.2 58.45 59.6 59.6 93.9 } 1 }
17+
{ 7.1 22.3 { 2.5 4.78 5.3 8.89 9.4 14.789 22.3 43.78 } 1 }
18+
{ 7.2 4.78 { 2.5 4.78 5.3 8.89 9.4 14.789 22.3 43.78 66.6 } 1 }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ 1 15 { } 0 }
2+
{ 2.1 15 { 2 15 16 } 1 }
3+
{ 2.2 15 { -2 15 } 1 }
4+
{ 2.3 15 { 15 17 30 } 1 }
5+
{ 3.1 15 { -43 -42 -39 -35 -30 -28 -26 -20 -15 -14 -12 -10 -8 -6 -3 -1 0 1 3 5 6 8 10 11 15 18 19 22 28 30 34 39 41 49 58 59 61 93 } 1 }
6+
{ 3.2 15 { -434 -431 -420 -410 -400 -399 -390 -380 -371 -340 -320 -315 -309 -301 -300 -290 -289 -271 -270 -260 -222 -211 -199 -100 -43 -12 -8 -4 -1 0 1 2 4 5 6 8 9 11 15 35 94 124 165 244 564 933 1145 1255 1599 2222 3445 9325 35553 44554 99949 134412 255355 459999 699455 999999 } 1 }
7+
{ 4.1 -1000 { -2000455346 -333444666 -1000 0 543534 324565345 1999888777 } 1 }
8+
{ 4.2 222333444 { -1000000000 -500000 -100 44444 222333444 200000000 } 1 }
9+
{ 5.1 61 { -43 -42 -39 -35 -30 -28 -26 -20 -15 -14 -12 -10 -8 -6 -3 -1 0 1 3 5 6 8 10 11 15 18 19 22 28 30 34 39 41 49 58 59 61 93 } 1 }
10+
{ 5.2 -39 { -43 -42 -39 -35 -30 -28 -26 -20 -15 -14 -12 -10 -8 -6 -3 -1 0 1 3 5 6 8 10 11 15 18 19 22 28 30 34 39 41 49 58 59 61 93 } 1 }
11+
{ 5.3 93 { -43 -42 -39 -35 -30 -28 -26 -20 -15 -14 -12 -10 -8 -6 -3 -1 0 1 3 5 6 8 10 11 15 18 19 22 28 30 34 39 41 49 58 59 61 93 } 1 }
12+
{ 5.4 -43 { -43 -42 -39 -35 -30 -28 -26 -20 -15 -14 -12 -10 -8 -6 -3 -1 0 1 3 5 6 8 10 11 15 18 19 22 28 30 34 39 41 49 58 59 61 93 } 1 }
13+
{ 6.1 30 { -43 -43 -39 -35 -30 -28 -28 -28 -15 -14 -12 -10 -10 -10 -10 -1 0 1 1 5 6 8 8 8 8 8 19 22 28 30 34 34 34 34 58 59 59 93 } 1 }
14+
{ 6.2 -43 { -43 -43 -39 -35 -30 -28 -28 -28 -15 -14 -12 -10 -10 -10 -10 -1 0 1 1 5 6 8 8 8 8 8 19 22 28 30 34 34 34 34 58 59 59 93 } 1 }
15+
{ 6.3 8 { -43 -43 -39 -35 -30 -28 -28 -28 -15 -14 -12 -10 -10 -10 -10 -1 0 1 1 5 6 8 8 8 8 8 19 22 28 30 34 34 34 34 58 59 59 93 } 1 }
16+
{ 6.4 59 { -43 -43 -39 -35 -30 -28 -28 -28 -15 -14 -12 -10 -10 -10 -10 -1 0 1 1 5 6 8 8 8 8 8 19 22 28 30 34 34 34 34 58 59 59 93 } 1 }
17+
{ 7.1 22 { 2 4 5 8 9 14 22 43 } 1 }
18+
{ 7.2 4 { 2 4 5 8 9 14 22 43 66 } 1 }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ 1 as { } 0 }
2+
{ 2.1 dfg { asd dfg rgrg } 1 }
3+
{ 2.2 dfg { asdg dfg } 1 }
4+
{ 2.3 dfg { dfg fhrh zgrgrgr } 1 }
5+
{ 3.1 cagr { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr esgrg fegr fkrht gafef gergt hrhth hzhr ichrt imth jagr jfe kerg klyhy lfeg loyth mfef mmyj naf nzgrg oefe ovrvd pasdf porty qasdf qvnnt ragr rrer saghr sbt tagr ttgtrh uagar ubertb vcegtr vzaf wasdgrt wzgrg xasghe xntrg yaafsd yytu za zzz } 1 }
6+
{ 3.2 rrer { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr esgrg fegr fkrht gafef gergt hrhth hzhr ichrt imth jagr jfe kerg klyhy lfeg loyth mfef mmyj naf nzgrg oefe ovrvd pasdf porty qasdf qvnnt ragr rrer saghr sbt tagr ttgtrh uagar ubertb vcegtr vzaf wasdgrt wzgrg xasghe xntrg yaafsd yytu za zzz } 1 }
7+
{ 4.1 asaasdasdasargaregaserg9seryguw8oe5tgyhw9ep58tghypwe80gyuw9e5ytgpw8eryhgpwergywerg { asaasdasdasargaregaserg9seryguw8oe5tgyhw9ep58tghypwe80gyuw9e5ytgpw8eryhgpwergywerg brgergeghqerggbbbbbrbrbrbbbbbbbbbbb vvevvvvvvvvvvvvweargrgherogi yagaorigheroghqrgagafgag zzzzzz } 1 }
8+
{ 4.2 mmm { aaafae fegreighergfffffffffffffffffffffffffffffffffff jjfijiwejfier mmm yfawefhaeofhergarh zzzzzzzzz } 1 }
9+
{ 5.1 agr { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr esgrg fegr fkrht gafef gergt hrhth hzhr ichrt imth jagr jfe kerg klyhy lfeg loyth mfef mmyj naf nzgrg oefe ovrvd pasdf porty qasdf qvnnt ragr rrer saghr sbt tagr ttgtrh uagar ubertb vcegtr vzaf wasdgrt wzgrg xasghe xntrg yaafsd yytu za zzz } 1 }
10+
{ 5.2 azgrg { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr esgrg fegr fkrht gafef gergt hrhth hzhr ichrt imth jagr jfe kerg klyhy lfeg loyth mfef mmyj naf nzgrg oefe ovrvd pasdf porty qasdf qvnnt ragr rrer saghr sbt tagr ttgtrh uagar ubertb vcegtr vzaf wasdgrt wzgrg xasghe xntrg yaafsd yytu za zzz } 1 }
11+
{ 5.3 yytu { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr esgrg fegr fkrht gafef gergt hrhth hzhr ichrt imth jagr jfe kerg klyhy lfeg loyth mfef mmyj naf nzgrg oefe ovrvd pasdf porty qasdf qvnnt ragr rrer saghr sbt tagr ttgtrh uagar ubertb vcegtr vzaf wasdgrt wzgrg xasghe xntrg yaafsd yytu za zzz } 1 }
12+
{ 5.4 zzz { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr esgrg fegr fkrht gafef gergt hrhth hzhr ichrt imth jagr jfe kerg klyhy lfeg loyth mfef mmyj naf nzgrg oefe ovrvd pasdf porty qasdf qvnnt ragr rrer saghr sbt tagr ttgtrh uagar ubertb vcegtr vzaf wasdgrt wzgrg xasghe xntrg yaafsd yytu za zzz } 1 }
13+
{ 6.1 agr { agr agr agr agr cagr cbrb dgrg dxtgr efgr efgr efgr fkrht gafef gergt hrhth hzhr hzhr hzhr hzhr hzhr hzhr hzhr hzhr loyth mfef mmyj mmyj nzgrg oefe ovrvd pasdf porty qasdf qasdf qasdf qasdf saghr sbt sbt sbt uagar ubertb vcegtr vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf } 1 }
14+
{ 6.2 gergt { agr agr agr agr cagr cbrb dgrg dxtgr efgr efgr efgr fkrht gafef gergt hrhth hzhr hzhr hzhr hzhr hzhr hzhr hzhr hzhr loyth mfef mmyj mmyj nzgrg oefe ovrvd pasdf porty qasdf qasdf qasdf qasdf saghr sbt sbt sbt uagar ubertb vcegtr vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf } 1 }
15+
{ 6.3 sbt { agr agr agr agr cagr cbrb dgrg dxtgr efgr efgr efgr fkrht gafef gergt hrhth hzhr hzhr hzhr hzhr hzhr hzhr hzhr hzhr loyth mfef mmyj mmyj nzgrg oefe ovrvd pasdf porty qasdf qasdf qasdf qasdf saghr sbt sbt sbt uagar ubertb vcegtr vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf } 1 }
16+
{ 6.4 vzaf { agr agr agr agr cagr cbrb dgrg dxtgr efgr efgr efgr fkrht gafef gergt hrhth hzhr hzhr hzhr hzhr hzhr hzhr hzhr hzhr loyth mfef mmyj mmyj nzgrg oefe ovrvd pasdf porty qasdf qasdf qasdf qasdf saghr sbt sbt sbt uagar ubertb vcegtr vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf vzaf } 1 }
17+
{ 7.1 azgrg { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr } 1 }
18+
{ 7.2 cbrb { agr azgrg brty bzhgr cagr cbrb dgrg dxtgr efgr } 1 }

‎Chapter_26/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,26 @@ set (FILE_NAME C26_BinarySearch_01)
1313
set (SOURCE_CXX_LIST ${FILE_NAME}.cpp)
1414
set (FILE_NAME2 C26_Exercise_26.1)
1515
set (SOURCE_CXX_LIST2 ${FILE_NAME2}.cpp)
16+
set (FILE_NAME3 C26_Exercise_26.2)
17+
set (SOURCE_CXX_LIST3 ${FILE_NAME3}.cpp)
18+
1619

1720
# Add source to this project's executable.
1821
add_executable (${FILE_NAME} ${SOURCE_CXX_LIST})
1922
add_executable (${FILE_NAME2} ${SOURCE_CXX_LIST2})
23+
add_executable (${FILE_NAME3} ${SOURCE_CXX_LIST3})
2024

2125

2226
# TODO: Add tests and install targets if needed.
2327
install (TARGETS ${FILE_NAME} CONFIGURATIONS Debug DESTINATION Build/Debug)
2428
install (TARGETS ${FILE_NAME} CONFIGURATIONS Release DESTINATION Build)
2529
install (TARGETS ${FILE_NAME2} CONFIGURATIONS Debug DESTINATION Build/Debug)
2630
install (TARGETS ${FILE_NAME2} CONFIGURATIONS Release DESTINATION Build)
31+
install (TARGETS ${FILE_NAME3} CONFIGURATIONS Debug DESTINATION Build/Debug)
32+
install (TARGETS ${FILE_NAME3} CONFIGURATIONS Release DESTINATION Build)
33+
install (FILES C26_Exercise_26.2_test_int.txt CONFIGURATIONS Debug DESTINATION Build/Debug)
34+
install (FILES C26_Exercise_26.2_test_int.txt CONFIGURATIONS Release DESTINATION Build)
35+
install (FILES C26_Exercise_26.2_test_double.txt CONFIGURATIONS Debug DESTINATION Build/Debug)
36+
install (FILES C26_Exercise_26.2_test_double.txt CONFIGURATIONS Release DESTINATION Build)
37+
install (FILES C26_Exercise_26.2_test_string.txt CONFIGURATIONS Debug DESTINATION Build/Debug)
38+
install (FILES C26_Exercise_26.2_test_string.txt CONFIGURATIONS Release DESTINATION Build)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /