- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- #include<windows.h>
- using namespace std;
- int main()
- {
- float time, start, end, tmp;
- cout<<"請輸入要倒數的秒數: ";
- cin>>time;
- start=clock();
- while(end<time*1000){
- cout<<(clock()-start)/1000<<"秒";
- _sleep(25);
- system("cls");
-
- if ((clock() - start) >= time*1000) {
- cout << "Times Up!!經過了" << time << "秒!" << endl;
- break;
- }
- }
- system("pause");
- return 0;
- }
複製代碼 |