- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main()
- {
- re:
- system("cls");
- int sec;
- int c;
- double c1, c2;
- cout << "請輸入要數的秒數:";
- cin >> sec;
- c1 = clock();
- while (true)
- {
- c2 = clock();
- c = (c2 - c1) / 1000;
- cout << (c2 - c1) / 1000 << "秒" << endl;
- system("cls");
- if (c == sec)
- break;
- }
- cout << "時間到! 經過了" << sec <<"秒" << endl;;
- system("pause");
- goto re;
- return 0;
- }
複製代碼 |