Module 13: Points and Spans

This commit is contained in:
David Doblas Jiménez 2021-08-09 18:28:29 +02:00
parent 7e6b501283
commit fe2d2e391f
1 changed files with 25 additions and 2 deletions

27
a.c
View File

@ -33,6 +33,23 @@ ostream& operator<<(ostream& os, const Point& p) { // for printing
return os;
}
// --------------------------------------------------------------------------------
//-Span
struct Span {
Span(Point p, int l, bool v) : point(p), len(l), vert(v) {}
friend ostream& operator<<(ostream& os, const Span& s);
Point point;
int len;
bool vert;
};
ostream& operator<<(ostream& os, const Span& s) {
os << "[" << s.point << " len=" << s.len << " vert=" << s.vert << "]";
return os;
}
// --------------------------------------------------------------------------------
//-Word
struct Word {
@ -187,8 +204,6 @@ int main() {
Library lib;
lib.ReadFromFile("top_12000.txt");
lib.FindWord("D--");
Grid grid("MY GRID");
grid.LoadFromFile("test");
grid.Check();
@ -199,4 +214,12 @@ int main() {
cout << "Point1 is " << p1 << "\n";
cout << "Point2 is " << p2 << "\n";
Span s1(p1, 3, true);
Span s2(p2, 5, false);
cout << "Span1 is " << s1 << "\n";
cout << "Span2 is " << s2 << "\n";
}