欢迎DaLao指导

博客名称

你的一句话介绍

get the runing time of C++ console program.

// 获取程序运行时间.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;
}

posted @ 2014-03-18 11:32  麻辣咸鱼  阅读(245)  评论(0编辑  收藏  举报