- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- float sec, start, end;
- cout<<"輸入要倒數的秒數!"<<endl;
- cin>>sec;
- start=clock();
- while(true)
- {
- if((clock()-start)/1000>sec)
- break;
- cout<<sec-(clock()-start)/1000<<endl;
- _sleep(50);
- system("cls");
- }
- cout<<"時間到,經過了"<<sec<<"秒!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |