c++计算程序运行时间

来源:互联网 发布:sep软件 编辑:程序博客网 时间:2024/05/16 19:26
  1. #include<iostream.h>  
  2. #include<time.h>  
  3. void main()  
  4. {  
  5.     clock_t start,finish;  
  6.     double totaltime;  
  7.     start=clock();  
  8.   /*
  9.     …… 程序代码                    
  10.   */
  11.     finish=clock();  
  12.     totaltime=(double)(finish-start)/CLOCKS_PER_SEC;  
  13.     cout<<"/n此程序的运行时间为"<<totaltime<<"秒!"<<endl;  
  14. }  
原创粉丝点击