#include
#include
#include
//计算时间,调用第一次与第二次之间时间段,第三次与第四次时间段,以此类推。
void clock_mark()
{
static clock_t start;
static clock_t end;
static int t;
if(t==0)
{
start=clock();
printf("\n*****计时开始*****\n");
t=1;
}
else
{
end=clock();
double cost_time=(double)((end-start)/CLOCKS_PER_SEC);
printf("\n*****计时结束Cost: %f seconds*****\n",cost_time);
t=0;
}
}
int main()
{
clock_mark();
。。。。。。 //计时的范围
clock_mark();
clock_mark();
。。。。。。 //计时的范围
clock_mark();
exit(0);
}
C语言计时函数
最新推荐文章于 2025-02-04 00:15:00 发布