C 練習(xí)實(shí)例93
題目:時(shí)間函數(shù)舉例2
程序分析:無(wú)。
程序源代碼:
// Created by hgci.cn on 15/11/9. // Copyright © 2015年 W3Cschool教程. 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次空循環(huán)需要的時(shí)間為",i); start=clock(); while(i--); finish=clock(); TheTimes=(double)(finish-start)/CLOCKS_PER_SEC; printf("%f秒。\n",TheTimes); return 0; }
以上實(shí)例運(yùn)行輸出結(jié)果為:
做10000000次空循環(huán)需要的時(shí)間為0.025367秒。
更多建議: