mirror of
https://gitflic.ru/project/w0lf/bulls-and-cows-cpp.git
synced 2026-03-28 16:02:46 +03:00
Fixed memory leak.
This commit is contained in:
@@ -46,7 +46,7 @@ void CGame::Start()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
PrintGameHeader();
|
PrintGameHeader();
|
||||||
ShowGuessedNumber(false);
|
ShowGuessedNumber(true);
|
||||||
PrintSteps();
|
PrintSteps();
|
||||||
ret = GetNumber(step);
|
ret = GetNumber(step);
|
||||||
switch (ret)
|
switch (ret)
|
||||||
@@ -169,3 +169,8 @@ int CGame::GetNumber(CStep step)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGame::~CGame()
|
||||||
|
{
|
||||||
|
delete[] m_uGuessedNumber;
|
||||||
|
}
|
||||||
|
|||||||
@@ -36,18 +36,18 @@ public:
|
|||||||
void Init(int);
|
void Init(int);
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
|
~CGame();
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename N>
|
template<typename T, typename N>
|
||||||
bool CGame::IsEqual(const T number, const N digit, int i)
|
bool CGame::IsEqual(const T number, const N digit, int i)
|
||||||
{
|
{
|
||||||
i--;
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
while (i >= 0)
|
while ((--i) >= 0)
|
||||||
{
|
{
|
||||||
if (digit == number[i]) result = true;
|
if (digit == number[i]) result = true;
|
||||||
i--;
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user