如何在 5 秒内迭代向量 5?
例子:
for(int i = 0; i < count; i++) {
cout << vector[count] << endl;
//sleep 5 seconds
}
谢谢!
如何在 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));
}
您也可以使用Sleep(n)
from<windows.h>
替代。