我有一个在 do while 循环中运行的 while 循环。我需要 while 循环准确地每秒运行一次,不快也不慢。但我不确定我会怎么做。这是循环,在它自己的函数中关闭。我听说过 sleep() 函数,但我也听说它不是很准确。
int min5()
{
int second = 00;
int minute = 0;
const int ZERO = 00;
do{
while (second <= 59){
if(minute == 5) break;
second += 1;
if(second == 60) minute += 1;
if(second == 60) second = ZERO;
if(second < 60) cout << "Current Time> "<< minute <<" : "<< second <<" \n";
}
} while (minute <= 5);
}