近段时间在学习时间函数,可是我的TC里总是说我没有定义CLOCKS_PER_SEC,加上头文件TIME.H也不管用.
怎么办,要是头文件里真的没有定义那我该怎么定义CLOCKS_PER_SEC呢?高手请指教啊.不行了.急急急!!
近段时间在学习时间函数,可是我的TC里总是说我没有定义CLOCKS_PER_SEC,加上头文件TIME.H也不管用.
怎么办,要是头文件里真的没有定义那我该怎么定义CLOCKS_PER_SEC呢?高手请指教啊.不行了.急急急!!
#i nclude “stdio.h”
#i nclude “stdlib.h”
#i nclude “time.h”
int main( void )
{
long i = 10000000L;
clock_t start, finish;
double duration;
/* 测量一个事件持续的时间*/
printf( "Time to do %ld empty loops is ", i );
start = clock();
while( i-- ) ;
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf( "%f seconds\n", duration );
system("pause");
}
那这个程序如何在TC里实现.
#i nclude “stdio.h”
#i nclude “stdlib.h”
#i nclude “time.h”
#define CLOCKS_PER_SEC 1000
int main( void )
{
long i = 10000000L;
clock_t start, finish;
double duration;
/* 测量一个事件持续的时间*/
printf( "Time to do %ld empty loops is ", i );
start = clock();
while( i-- ) ;
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf( "%f seconds\n", duration );
system("pause");
}
[此贴子已经被作者于2007-9-30 15:01:35编辑过]