返回列表 發帖

clock() 函式

clock() 函式能回傳自程式執行開始, 經過的毫秒數!
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl;
  10.     system("pause");
  11.     return 0;   
  12. }
複製代碼

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl;
  10.     system("pause");
  11.     return 0;
  12. }
複製代碼
Huang chenhao

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl;
  10.     system("pause");
  11.     return 0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl;
  10.     system("pause");
  11.     return 0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl;
  10.     system("pause");
  11.     return 0;   
  12. }
複製代碼
李宇澤Oscar

TOP

  1. #include<cstdlib>
  2. #include<iostream>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時中";
  8.     system("pause");
  9.    
  10.     cout<<"過了"<<clock()<<"毫秒";
  11.     system("pause");
  12.     return 0;   
  13. }
複製代碼
hahahahahahahaha

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl;
  10.     system("pause");
  11.     return 0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     cout<<"計時開始!"<<endl;
  8.     system("pause");
  9.     cout<<"自程式執行開始,經過了"<<clock()<<"毫秒"<<endl;
  10.     system("pause");
  11.     return 0;   
  12. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.      cout<<"計時開始!"<<endl<<endl;
  8.      system("pause");
  9.      cout<<endl;
  10.      cout<<"自程式執行開始,經過了"<<clock()<<"毫秒!"<<endl<<endl;
  11.      system("pause");
  12.      return 0;
  13. }
複製代碼

TOP

本帖最後由 陳宥穎 於 2020-4-17 19:54 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int p(int a)
  6. {
  7.     return a/1000;
  8. }
  9. int main()
  10. {
  11.     cout<<"計時開始!"<<endl;
  12.     system("pause");
  13.     cout<<"自程式執行開始,經過了\n"<<clock()<<"毫秒!\n"<<p(clock())<<"秒!"<<endl;;
  14.    
  15.     system("pause");
  16.     return 0;   
  17. }
複製代碼

TOP

返回列表