diff --git a/CardGame.Test.GamePlay2/CardGame.Test.GamePlay2.cpp b/CardGame.Test.GamePlay2/CardGame.Test.GamePlay2.cpp index ea52fe7..98b59dd 100644 --- a/CardGame.Test.GamePlay2/CardGame.Test.GamePlay2.cpp +++ b/CardGame.Test.GamePlay2/CardGame.Test.GamePlay2.cpp @@ -37,6 +37,7 @@ void DealCards(int N, SqList*& PA, SqList*& PB, int times) delete[] CardPile; // 释放发牌堆占用的内存 } +// 输出B的手牌 void DisplayPlayerBCards(int*& QB, int N) { for (int i = 0; i < N; i++) @@ -45,7 +46,7 @@ void DisplayPlayerBCards(int*& QB, int N) cout << endl; } -bool IsPlayerBWin(int*& QB, int N) +bool IsPlayerAWin(int*& QB, int N) { for (int i = 0; i < N; i++) if (QB[i] > 0) return false; @@ -153,7 +154,7 @@ int GamePlay2(SqList& PA, SqList& PB, int N) winner = 2; break; } - else if (IsPlayerBWin(QB, N)) + else if (IsPlayerAWin(QB, N)) { winner = 1; break; diff --git a/CardGame/GamePlay1.cpp b/CardGame/GamePlay1.cpp index b3a1f95..16f2a64 100644 --- a/CardGame/GamePlay1.cpp +++ b/CardGame/GamePlay1.cpp @@ -43,11 +43,13 @@ void GamePlay1(SqList& PA, SqList& PB, int N) { int x = 0; // 双方交替出牌 - if (i++ % 2 == 0) { + if (i++ % 2 == 0) // 奇数回合A出牌 + { DeQueue(*QA, a); x = a; } - else { + else // 偶数回合B出牌 + { DeQueue(*QB, b); x = b; } diff --git a/CardGame/GamePlay2.cpp b/CardGame/GamePlay2.cpp index 6f906f4..54445e0 100644 --- a/CardGame/GamePlay2.cpp +++ b/CardGame/GamePlay2.cpp @@ -6,6 +6,7 @@ using namespace std; #include "FuncRef.h" #include "Functions.h" +// 输出B的手牌 void DisplayPlayerBCards(int*& QB, int N) { for (int i = 0; i < N; i++) @@ -26,7 +27,7 @@ void DisplayStatus(SqQueue& QA, int*& QB, SqStack& Desk, int i, int N) DispStack(Desk); } -bool IsPlayerBWin(int*& QB, int N) +bool IsPlayerAWin(int*& QB, int N) { for (int i = 0; i < N; i++) if (QB[i] > 0) return false; @@ -134,7 +135,7 @@ void GamePlay2(SqList& PA, SqList& PB, int N) cout << "Player B wins!" << endl; break; } - else if (IsPlayerBWin(QB, N)) + else if (IsPlayerAWin(QB, N)) { cout << "Player A wins!" << endl; break; diff --git a/ExpReportTemplate.docx b/ExpReportTemplate.docx new file mode 100644 index 0000000..06143b6 Binary files /dev/null and b/ExpReportTemplate.docx differ diff --git a/ExpReportTemplate.dotx b/ExpReportTemplate.dotx deleted file mode 100644 index d92ed53..0000000 Binary files a/ExpReportTemplate.dotx and /dev/null differ diff --git a/include/Functions.h b/include/Functions.h index 13fbf5c..a98f107 100644 --- a/include/Functions.h +++ b/include/Functions.h @@ -18,12 +18,12 @@ inline void DealCards(int N, SqList*& PA, SqList*& PB) { if (CardPile[num] != 0) // 如果该数对应面值的牌未发完 { - if (i % 2 == 0) // 发给PA + if (i % 2 == 0) // 如果发牌次数(i+1)为奇数,则发给PA { InsertElem_i(*PA, j++, num + 1); CardPile[num]--; } - else // 发给PB + else // 否则发给PB { InsertElem_i(*PB, k++, num + 1); CardPile[num]--; @@ -49,10 +49,4 @@ inline int FindElem(SqStack& S, int e) inline bool IsPlayerA(int i) { return i % 2 == 1; -} - -// 返回栈元素数量 -inline int StackSize(SqStack& S) -{ - return S.top + 1; } \ No newline at end of file