fix
This commit is contained in:
@@ -37,6 +37,7 @@ void DealCards(int N, SqList<int>*& PA, SqList<int>*& 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<int>& PA, SqList<int>& PB, int N)
|
||||
winner = 2;
|
||||
break;
|
||||
}
|
||||
else if (IsPlayerBWin(QB, N))
|
||||
else if (IsPlayerAWin(QB, N))
|
||||
{
|
||||
winner = 1;
|
||||
break;
|
||||
|
||||
@@ -43,11 +43,13 @@ void GamePlay1(SqList<int>& PA, SqList<int>& 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;
|
||||
}
|
||||
|
||||
@@ -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<int>& QA, int*& QB, SqStack<int>& 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<int>& PA, SqList<int>& 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;
|
||||
|
||||
BIN
ExpReportTemplate.docx
Normal file
BIN
ExpReportTemplate.docx
Normal file
Binary file not shown.
Binary file not shown.
@@ -18,12 +18,12 @@ inline void DealCards(int N, SqList<int>*& PA, SqList<int>*& 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]--;
|
||||
@@ -50,9 +50,3 @@ inline bool IsPlayerA(int i)
|
||||
{
|
||||
return i % 2 == 1;
|
||||
}
|
||||
|
||||
// 返回栈元素数量
|
||||
inline int StackSize(SqStack<int>& S)
|
||||
{
|
||||
return S.top + 1;
|
||||
}
|
||||
Reference in New Issue
Block a user