返回列表 發帖
本帖最後由 吳孟修 於 2019-6-1 13:40 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int sec;
  8.     double c1, c2;
  9.     int c;
  10.     cout<<"請輸入要數的秒數: ";
  11.     cin>>sec;
  12.     c1=clock();
  13.     while(c!=sec)
  14.     {
  15.          c2=clock();
  16.          c=(c2-c1)/1000;      
  17.          cout<<"已經過了"<<(c2-c1)/1000<<"秒.";
  18.          system("cls");
  19.     }
  20.     cout<<"時間到,共經過了"<<sec<<"秒!"<<endl;
  21.     system("pause");
  22.     system("cls");
  23.     goto re;     
  24.     return 0;   
  25. }
複製代碼

TOP

返回列表