題目:時間函式舉例2
程式分析:無,
程式源代碼:
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 5 int main() 6 { 7 long i=10000000L; 8 clock_t start,finish; 9 double TheTimes; 10 printf("做%ld次慷訓圈需要的時間為",i); 11 start=clock(); 12 while(i--); 13 finish=clock(); 14 TheTimes=(double)(finish-start)/CLOCKS_PER_SEC; 15 printf("%f秒,\n",TheTimes); 16 return 0; 17 }
以上實體運行輸出結果為:
做10000000次慷訓圈需要的時間為0.025367秒,
感謝你的閱讀,請用心感悟!希望可以幫到愛學習的你!!分享也是一種快樂!!!請接力,,,
點擊查看原文,謝謝!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/1870.html
標籤:C
上一篇:C 實戰練習題目92
