C 练习实例93
C 语言教程
· 2019-02-22 17:13:01
题目:时间函数举例2
程序分析:无。
程序源代码:
// Created by www.codercto.com on 15/11/9.
// Copyright © 2015年 码农教程. All rights reserved.
//
#include <stdio.h>
#include <stdlib.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.025367秒。
点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html