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