您的位置:首页 > 编程语言 > C语言/C++

get the runing time of C++ console program.

2014-03-18 11:32 344 查看
// 获取程序运行时间.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <time.h>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
clock_t Start=0,Finish=0;
double Totaltime=0;
for(int i=0;i<10;i++)
{
//cout<<i;
if(i==5)
cout<<endl;
}
finish=clock();
totaltime=(double)(Finish-start)/CLOCKS_PER_SEC;
cout<<"\nfinish="<<Finish<<endl;
cout<<"\nstart="<<Start<<endl;
cout<<"\n此程序的运行到此的时间为:"<<totaltime<<"秒!,="<<totaltime/60<<"分!="<<totaltime/3600<<"小时!"<<endl;
return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐