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