#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;
}
摘自:KidLeaf2的專欄