记录时间的方法

https://blog.csdn.net/xiong452980729/article/details/51394036

    #include<iostream>
    #include<time.h>  

    using namespace std;  

    int main()  
    {  
        clock_t startTime,endTime;  
        startTime = clock();  
        for (int i = 0; i < 1000000; i++)  
        {  
            i++;  
        }  
        endTime = clock();  
        cout << "Totle Time : " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;  
        system("pause");  
        return 0;  
    }
#include<iostream>  
#include<time.h>  

using namespace std;  

int main()  
{  
    for (int i = 0; i < 1000000; i++)  
    {  
        i++;  
    }  
    cout << "Totle Time : " << (double)clock() /CLOCKS_PER_SEC<< "s" << endl;  
    system("pause");  
    return 0;  
}

 

posted @ 2018-05-13 11:46  *Miracle*  阅读(763)  评论(0编辑  收藏  举报