5秒内迭代向量5
Iteration vector 5 in 5 seconds c
如何在5秒内迭代向量5 ?
的例子:
for(int i = 0; i < count; i++) {
cout << vector[count] << endl;
//sleep 5 seconds
}
谢谢!
假设向量有5个元素:
#include <chrono>
#include <thread> /* introduced with c++11,
make sure your compiler is up to date
and is set to compile c++ with this version
of the STL and standard
*/
<一口>一口>
for (int i = 0; i < count; ++i)
{
cout << vector[count] << endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
您也可以选择使用<windows.h>
中的Sleep(n)
相关文章:
- std::向量迭代器和调整大小/保留的奇怪/有趣行为
- 如何取消引用向量迭代器
- Map中的(字符串的)向量迭代器
- C++将向量迭代器转换为索引
- yaml-cpp到std::向量迭代的怪异行为
- 使用索引与迭代器将向量迭代到倒数第二个元素
- 无法取消引用超出范围的向量迭代器 - 有什么问题?
- 向量迭代器不兼容的错误,用于保存另一个向量的迭代器的向量
- C++向量迭代器nth_element编译错误
- 无法查找值初始化的向量迭代器?
- C++向量迭代:常量 vs. 常量自动 vs. 无常量
- 向量迭代编译为非常不同的指令
- STD ::向量迭代器类型和允许的操作
- 如何通过尺寸未知的2D向量迭代
- 向量迭代器 < 或 !=
- 如何通过共享_ptr向量迭代
- 如何通过向量迭代作为指针
- 通过向量迭代,而其他线程可能会对其进行修改
- 我如何通过C 中的字符串向量迭代
- 向量迭代器在新对象的 push_back() 之后不兼容