Module 13: Add Point structure
This commit is contained in:
parent
b27c93dfd2
commit
c34f2307c0
31
a.c
31
a.c
@ -17,6 +17,22 @@ string ToUpper(string s) {
|
||||
return s2;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
//-Point
|
||||
struct Point {
|
||||
Point() {}
|
||||
Point(int r, int c) : row(r), col(c) {}
|
||||
|
||||
friend ostream& operator<<(ostream& os, const Point& p); // overloading the "<<" op
|
||||
int row = 0; // defaults value for the constructor
|
||||
int col = 0;
|
||||
};
|
||||
|
||||
ostream& operator<<(ostream& os, const Point& p) { // for printing
|
||||
os << "(" << p.row << "," << p.col << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
//-Word
|
||||
struct Word {
|
||||
@ -78,6 +94,7 @@ public:
|
||||
}
|
||||
void CreatePatternHash(Word* w) {
|
||||
int len = w->len();
|
||||
if (len > 7) return; // avoid load of long words
|
||||
int num_patterns = 1 << len; // create 2^len patterns
|
||||
// cout << "PATTERN HASH on " << w->word << "\n";
|
||||
for (int i=0; i<num_patterns; i++) {
|
||||
@ -172,8 +189,14 @@ int main() {
|
||||
|
||||
lib.FindWord("D--");
|
||||
|
||||
//Grid grid("MY GRID");
|
||||
//grid.LoadFromFile("test");
|
||||
//grid.Check();
|
||||
//grid.Print();
|
||||
Grid grid("MY GRID");
|
||||
grid.LoadFromFile("test");
|
||||
grid.Check();
|
||||
grid.Print();
|
||||
|
||||
Point p1;
|
||||
Point p2(2,1);
|
||||
|
||||
cout << "Point1 is " << p1 << "\n";
|
||||
cout << "Point2 is " << p2 << "\n";
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user