19 |
***************************************************************************/ |
***************************************************************************/ |
20 |
#include "solution.h" |
#include "solution.h" |
21 |
|
|
22 |
#include <iostream> |
Solution::Solution(int size) |
23 |
|
{ |
24 |
|
m_size = size; |
25 |
|
|
26 |
|
for (int i=0; i<size; i++) |
27 |
|
{ |
28 |
|
m_matrix[i] = -1; |
29 |
|
} |
30 |
|
} |
31 |
|
|
|
using namespace std; |
|
32 |
|
|
33 |
void Solution::print() |
Solution::~Solution() |
34 |
{ |
{ |
|
print(false, -1, -1); |
|
35 |
} |
} |
36 |
|
|
37 |
void Solution::print(bool debug, int row, int col) |
Solution::Solution(const Solution& input) |
38 |
{ |
{ |
39 |
for (int i=0; i<m_size; i++) { |
m_size = input.m_size; |
40 |
for (int j=0; j<m_size; j++) |
for (int i=0; i<m_size; i++) |
41 |
cout << "+--"; |
m_matrix[i] = input.m_matrix[i]; |
|
cout << "+" << endl; |
|
|
for (int j=0; j<m_size; j++) { |
|
|
cout << "|"; |
|
|
if (debug==true && row!=-1 && i==row && j==col) |
|
|
cout << "??"; |
|
|
else |
|
|
cout << ( getMatrix(i,j)==true ? "QQ" : " "); |
|
|
} |
|
|
cout << "|" << endl; |
|
|
} |
|
|
for (int j=0; j<m_size; j++) |
|
|
cout << "+--"; |
|
|
cout << "+" << endl; |
|
42 |
} |
} |
43 |
|
|
44 |
|
/* |
45 |
|
void Solution::set(unsigned char input[MAX_SIZE]) |
46 |
|
{ |
47 |
|
for (int i=0; i<m_size; i++) |
48 |
|
m_matrix[i] = input[i]; |
49 |
|
}*/ |
50 |
|
|
51 |
|
/* |
52 |
|
inline bool Solution::getMatrix(int x, int y) |
53 |
|
{ |
54 |
|
return (m_matrix[x] == y); |
55 |
|
}*/ |
56 |
|
/* |
57 |
|
void Solution::setMatrix(int x, int y, bool val) |
58 |
|
{ |
59 |
|
if (val == true) |
60 |
|
m_matrix[x] = y; |
61 |
|
else |
62 |
|
m_matrix[x] = -1; |
63 |
|
}*/ |
64 |
|
|
65 |
|
bool Solution::operator ==(const Solution& s) |
66 |
|
{ |
67 |
|
const Solution& sol = dynamic_cast<const Solution&>(s); |
68 |
|
for (int i=0; i<m_size; i++) |
69 |
|
if (m_matrix[i] != sol.m_matrix[i]) |
70 |
|
return false; |
71 |
|
return true; |
72 |
|
} |
73 |
|
|
74 |
|
Solution* Solution::copy() |
75 |
|
{ |
76 |
|
return new Solution(*this); |
77 |
|
} |
78 |
|
|
79 |
|
/* |
80 |
|
void Solution::mirror() |
81 |
|
{ |
82 |
|
unsigned char temp[MAX_SIZE]; |
83 |
|
for (int i=0; i<m_size; i++) |
84 |
|
temp[i] = (m_size-1) - m_matrix[i]; |
85 |
|
set( temp ); |
86 |
|
}*/ |
87 |
|
|
88 |
|
/* |
89 |
|
void Solution::rotate90() |
90 |
|
{ |
91 |
|
unsigned char temp[MAX_SIZE]; |
92 |
|
|
93 |
|
for (int i=0; i<m_size; i++) |
94 |
|
{ |
95 |
|
int x = i; |
96 |
|
int y = m_matrix[i]; |
97 |
|
|
98 |
|
temp[y] = (m_size-1) - x; |
99 |
|
} |
100 |
|
|
101 |
|
set( temp); |
102 |
|
}*/ |
103 |
|
|