feat(cmat): add cmake build for course material
Add a CMakeLists.txt to each exercise directory, included from cmat/CMakeLists.txt, so every exercise and solution becomes a buildable target. GUI exercises link the curses-based DOS_Unix implementations on Unix-like systems; the Windows-specific DOS variants are not compiled. Exercises without a portable path or with missing dependencies (Boost) are reported as not available at configure time. Targets are excluded from the default build and built by name, e.g. `cmake --build build --target Ex11`, so intentionally buggy exercises such as Ex21 do not break the default build. Also fix two portability issues: rename Ex11bug/pole.h to Pole.h for case-sensitive filesystems and drop the extra Light:: qualification in SolutionEx71A/Light.h. Document build commands and layout in AGENTS.md. Co-authored-by: Qwen 3.8 27B <qwen3.8_27b-q3_k_xl@lmstudio.local>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
|
||||
#include "Pixel.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
void pixelPrint(const Pixel &pixel) { pixel.print(); }
|
||||
|
||||
int main() {
|
||||
|
||||
// From Ex 3.1
|
||||
|
||||
// preamble
|
||||
Pixel pixel0;
|
||||
cout << "Preamble:" << endl;
|
||||
pixel0.print();
|
||||
cout << endl;
|
||||
|
||||
Pixel pixel1(1, 2);
|
||||
Pixel pixel2(3, 3);
|
||||
Pixel pixel3(2, 4);
|
||||
Pixel pixel4(5, 2);
|
||||
Pixel pixel5(4, 2);
|
||||
|
||||
// 3.1 part 1
|
||||
cout << "3.1 Part 1:" << endl;
|
||||
vector<Pixel> pixelVec;
|
||||
pixelVec.push_back(pixel1);
|
||||
pixelVec.push_back(pixel2);
|
||||
pixelVec.push_back(pixel3);
|
||||
pixelVec.push_back(pixel4);
|
||||
pixelVec.push_back(pixel5);
|
||||
|
||||
for (unsigned int i = 0; i < pixelVec.size(); ++i) {
|
||||
pixelVec[i].print();
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
// 3.1 part 2
|
||||
cout << "3.1 Part 2:" << endl;
|
||||
for (vector<Pixel>::iterator iter = pixelVec.begin(); iter != pixelVec.end(); ++iter) {
|
||||
iter->print();
|
||||
}
|
||||
cout << endl;
|
||||
for (vector<Pixel>::reverse_iterator r_iter = pixelVec.rbegin(); r_iter != pixelVec.rend(); ++r_iter) {
|
||||
r_iter->print();
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
vector<Pixel> pixelVec2{pixel1, pixel2, pixel3, pixel4, pixel5};
|
||||
for (const Pixel &p : pixelVec2) {
|
||||
p.print();
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
// 3.1 part 3
|
||||
cout << "3.1 Part 3:" << endl;
|
||||
for_each(pixelVec.begin(), pixelVec.end(), pixelPrint);
|
||||
cout << endl;
|
||||
sort(pixelVec.begin(), pixelVec.end());
|
||||
for_each(pixelVec.begin(), pixelVec.end(), pixelPrint);
|
||||
cout << endl;
|
||||
|
||||
// insert code here ***************************************
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user