1 //計算一段程序運行的時間
2 #include<iostream>
3 #include<time.h>
4 using namespace std;
5 int main()
6 {
7 clock_t startTime,endTime;
8 startTime = clock();//計時開始
9 for (int i = 0; i < 2147483640; i++)
10 {
11 i++;
12 }
13 endTime = clock();//計時結束
14 cout << "The run time is: " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;
15 system("pause");
16 return 0;
17 }
