1. 程式人生 > >c++ time.h clock()程式計時

c++ time.h clock()程式計時

#include<iostream.h>
#include<time.h>
void main()
{
   clock_t start,finish;
   double totaltime;
   start=clock();

   ……                     //把你的程式程式碼插入到這裡面

   finish=clock();
   totaltime=(double)(finish-start)/CLOCKS_PER_SEC;
   cout<<"\n此程式的執行時間為"<<totaltime<<"秒!"<<endl;
}