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

TOP

返回列表