如何在 for 循环内暂停
How can I pause inside a for loop
好吧,我可以暂停,问题是我所有的"暂停"都是累积的,而不是按顺序完成的。我尝试了很多时钟的东西,睡觉,..每次的结果都一样。我在这里错过了什么吗?我只是想这样做来帮助我进行可视化反馈编程,它不会留在代码中,所以任何东西,即使是肮脏的,都是受欢迎的!
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循环中添加两个数组
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 正在尝试了解输入验证循环
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- 循环后如何继续阅读
- 如何将循环暂停几秒钟?
- 如何在 for 循环内暂停
- 在 C++ 中暂停 For 循环 1 秒钟
- 暂停功能,它永远循环
- C++延迟 for 循环而不暂停控制台
- 用于在程序结束后暂停程序的有效循环
- 如何暂停for cicle(循环)以在数组中插入一些值
- C++不暂停执行的循环
- 暂停while循环
- 如何在不暂停循环的情况下使用字符输入停止循环
- 暂停循环,直到按下某个键
- 睡眠(0)和暂停指令的忙循环有什么不同
- c++暂停函数似乎不能在do-while循环中工作
- 暂停循环操作,直到用户提供完整的输入