C++程序运行时间

总是有些小技巧需要找个地方记录的。

#include <iostream>  
#include <ctime> 
#include <Windows.h>
using namespace std;

int main()   
{      
    clock_t start,finish;     
 
    start=clock();   
    Sleep(500);
    finish=clock();   

    double time = finish-start;   
    cout<<"过了"<<time<<"ms"<<endl;

    system("pause"); 
    return 0;
}  

 

posted @ 2013-03-13 17:09  Dsp Tian  阅读(674)  评论(0编辑  收藏  举报