diff --git a/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp b/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp index 6689132..e8675f5 100644 --- a/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp +++ b/TangDou/LuoGuBook/ZhiMuSanJiaoXing.cpp @@ -1,20 +1,16 @@ #include -using std::sort; -using std::cin; -using std::cout; -using std::endl; -using std::string; +using namespace std; int n, flag, axis; -string inStr, ans; -struct point { +string s, ans; +struct Node { int x, y; char v; // value }; -std::vector pt; -struct point inf; +vector pt; +struct Node inf; -bool comp(const point &a, const point &b) { +bool comp(const Node &a, const Node &b) { if (a.v == b.v) { return (a.x == b.x) ? (a.y < b.y) : (a.x < b.x); } else { @@ -22,32 +18,25 @@ bool comp(const point &a, const point &b) { } } int main() { - cin >> n >> inStr; - flag = 0, axis = 0; - for (register int count = 0; count < n; ++count) { - for (register int countB = 0; countB < count + 1; ++countB) { - point newPt; - newPt.v = inStr[flag]; - newPt.y = count; - newPt.x = axis + (countB << 1); + cin >> n >> s; + for (int i = 0; i < n; i++) { + for (int j = 0; j <= i; j++) { + Node newPt; + newPt.v = s[flag]; + newPt.y = i; + newPt.x = axis + (j << 1); ++flag; pt.push_back(newPt); - // used for debug - // cout<