gpt4 book ai didi

c++ - 如何在 for 循环内暂停

转载 作者:行者123 更新时间:2023-12-02 03:15:48 25 4
gpt4 key购买 nike

好吧,我可以暂停,问题是我所有的“暂停”都是累积的,而不是按顺序完成的。我尝试了很多时钟的东西, sleep ,..每次都有相同的结果。我在这里错过了什么吗?我只是想这样做来帮助我通过视觉反馈进行编程,它不会保留在代码中,所以任何东西,即使是肮脏的东西,都是受欢迎的!

void Dockable::resize_cells() {
for (int i = 0; i < cells.size(); i++) {
for (int j = 0; j < cells[i].size(); j++) {
if (cells[i][j] != layout) {
if (cells[i][j]->is.docked) {
int found_col = 0;
bool found = false;
int pos = 0;
for (int k = 0; k < cells.size(); k++) {
int col = 0;
for (int l = 0; l < cells[k].size(); l++) {
if (!found) {
if (cells[i][j] == cells[k][l]) {
found = true;
pos = col;
}
}
if (!(l - 1 < 0) &&
cells[k][l] != cells[k][l - 1]) {
col++;
}
else {
col++;
}
if (found) {
if (col > found_col) {
found_col = col;
}
}
}
}
cells[i][j]->x_size(layout->x_size() / found_col);
cells[i][j]->x((layout->x_size() / found_col) * pos);
cells[i][j]->refresh_shape_apply();
wait();
}
}
}
}
}
void Dockable::wait()
{
clock_t counter;
clock_t target;
counter = clock();
target = clock() + 100;
while (counter < target) {
counter = clock();
std::cout << counter << std::endl;
}
}

refresh_shape_apply,应用转换,因为它是在等待之前执行的,我希望它能起作用。

最佳答案

您可以使用此代码

system("pause");

这可以帮助暂停代码,直到您按任意字母继续。

关于c++ - 如何在 for 循环内暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59464237/

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