gpt4 book ai didi

c++ - .exe 不显示 "Press any key to continue..."

转载 作者:太空宇宙 更新时间:2023-11-04 16:06:14 25 4
gpt4 key购买 nike

enter image description here在 Visual Studio 中,每当我在没有调试的情况下启动时,显示的 .exe 文件不像通常那样包含短语“按任意键继续...”。屏幕的开头只有闪烁的光标。有什么简单的解决方法吗?我已经注释掉了我的一些代码,并且该短语重新显示。

这是我注释掉的代码:我正确声明了所有变量和类。

void Maze::addPaths()
{
Coordinate currentLocation;
Coordinate startLocation;
Coordinate endLocation; //not used yet
std::stack<Coordinate> stack;

currentLocation.row = (((rand() % HEIGHT) / 2) * 2);
currentLocation.column = (((rand() % WIDTH) / 2) * 2);

startLocation = currentLocation;
grid[currentLocation.row][currentLocation.column] = START;
player = currentLocation;
do
{
//drawMaze();
bool canMoveUp = !(currentLocation.row == 0 || grid[currentLocation.row - 2][currentLocation.column] != WALL);
bool canMoveDown = !(currentLocation.row == HEIGHT - 1 || grid[currentLocation.row + 2][currentLocation.column] != WALL);
bool canMoveLeft = !(currentLocation.column == 0 || grid[currentLocation.row][currentLocation.column - 2] != WALL);
bool canMoveRight = !(currentLocation.column == WIDTH - 1 || grid[currentLocation.row][currentLocation.column + 2] != WALL);

if (canMoveUp || canMoveDown || canMoveLeft || canMoveRight)
{
stack.push(currentLocation);

//choose random location to dig
bool moveFound = false;
while (!moveFound)
{
int direction = rand() % 4;
if (direction == 0 && canMoveUp)
{
moveFound = true;
grid[currentLocation.row - 2][currentLocation.column] = PATH;
grid[currentLocation.row - 1][currentLocation.column] = PATH;
currentLocation.row -= 2;
}
else if (direction == 1 && canMoveDown)
{
moveFound = true;
grid[currentLocation.row + 2][currentLocation.column] = PATH;
grid[currentLocation.row + 1][currentLocation.column] = PATH;
currentLocation.row += 2;
}
else if (direction == 2 && canMoveLeft)
{
moveFound = true;
grid[currentLocation.row][currentLocation.column - 2] = PATH;
grid[currentLocation.row][currentLocation.column - 1] = PATH;
currentLocation.column -= 2;
}
else if (direction == 3 && canMoveRight)
{
moveFound = true;
grid[currentLocation.row][currentLocation.column + 2] = PATH;
grid[currentLocation.row][currentLocation.column - 2] = PATH;
currentLocation.column += 2;
cout << "yay";
}
}
}
else if (!stack.empty())
{
currentLocation = stack.top();
stack.pop();
}
} while (!stack.empty());
//addDestinationToGrid();
cout << "no";
}

最佳答案

在 Windows 上,system("PAUSE"); 将提示用户文本:

Press any key to continue...

关于c++ - .exe 不显示 "Press any key to continue...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34804482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com