C++ Primer學習筆記第5章

// delay.cpp : 此文件包含 "main" 函數。程序執行將在此處開始並結束。
//

#include <iostream>
#include <ctime> //describes clock() function, clock_t type
using namespace std;

int main()
{
    std::cout << "Enter the delay time inseconds:";
    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";
    return 0;

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章