返回列表 發帖

數秒計時器

設計一程式, 讓使用者能指定秒數, 執行畫面如下:


  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. int main()
  6. {
  7.     re:
  8.     int sec;
  9.     double c1, c2;
  10.     int c;
  11.     cout<<"請輸入要數的秒數: ";
  12.     cin>>sec;
  13.     c1=clock();
  14.     while(c!=sec)
  15.     {
  16.          c2=clock();
  17.          c=(c2-c1)/1000;      
  18.          cout<<(c2-c1)/1000<<"秒!";
  19.          system("cls");
  20.     }
  21.     cout<<"時間到! 共經過了"<<sec<<"秒!"<<endl;
  22.     system("pause");
  23.     system("cls");
  24.     goto re;     
  25.     return 0;   
  26. }
複製代碼
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     re:
  7.     int sec, a=0;
  8.     cout<<"請輸入要數的秒數: "<<endl;
  9.     cin>>sec;
  10.     double a1, a2;
  11.     a1=clock();
  12.     while (sec!=a)
  13.     {
  14.           a2=clock();
  15.           a=(a2-a1)/1000;
  16.           cout<<(a2-a1)/1000;
  17.           system("cls");
  18.     }
  19.     cout<<"時間到!經過"<<sec<<"秒"<<endl;
  20.     system("pause");
  21.     system("cls");
  22.     goto re;
  23.     system("pause");     
  24.     return 0;   
  25. }
複製代碼

TOP

  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<<"請輸入要數的秒數"<<endl;
  11.   cin>>sec;
  12.   c1=clock();
  13.    while(c!=sec)
  14.      {
  15.       c2=clock();
  16.       c=(c2-c1)/1000;
  17.       cout<<(c2-c1)/1000<<"秒"<<endl;
  18.        system("cls");         
  19.      }
  20.     cout<<"<<時間到 經過了"<<sec<<"秒"<<endl;
  21.     system ("pause");
  22.     system("cls");
  23.     goto re;
  24.     return 0;   
  25. }
複製代碼

TOP

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

TOP

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

TOP

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

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int sec ,min=0;
  7.     double c1 ,c2;
  8.     cout<<"請輸入秒數:";
  9.     cin>>sec;
  10.     c1=clock();
  11.     while(sec!=min)
  12.     {
  13.         c2=clock();
  14.         min=(c2-c1)/1000;
  15.         cout<<(c2-c1)/1000<<endl;
  16.         system("cls");
  17.     }
  18.     cout<<"時間到! 經過了"<<sec<<"秒!"<<endl;
  19.     system("pause");
  20.     return 0;
  21. }
複製代碼

TOP

返回列表