C 練習實例93
題目:時間函數舉例2
程式分析:無。
程式源代碼:
// Created by www.xuhuhu.com on 15/11/9.
// Copyright © 2015年 IT研修. 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 語言經典100例