Skip to content

Latest commit

 

History

History
23 lines (22 loc) · 432 Bytes

93.md

File metadata and controls

23 lines (22 loc) · 432 Bytes

题目:时间函数举例。

#include <stdio.h>
#include <time.h>

int main()
{
	long i = 10000000L;
	clock_t start, finish;
	double TheTimes;
	printf("做%ld次空循环需要的时间为", i);
	start = clock();
	while (i--);
	finish = clock();
	TheTimes = (double)(finish - start) / CLOCKS_PER_SEC;
	printf("%f秒。\n", TheTimes);
	return 0;
}

结果:

做10000000次空循环需要的时间为0.024000秒。