C++语言开发示例:03. 等待

2024-07-14 07:54:54 2025-02-01 20:27:44 李腾 24 次阅读 0 次点赞

waiting.cpp

#include <iostream>
#include <ctime>

int main()
{
    using namespace std;
    cout << "Enter the delay time, in seconds: ";
    float secs;
    cin >> secs;
    clock_t delay = secs * CLOCKS_PER_SEC;
    cout << "starting\a\n";
    clock_t start = clock();
    while (clock() - start < delay)
        ;
    cout << "done\a\n";
}
本文由人工编写,AI优化,请仔细甄别,转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:03. 等待

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!