- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int n1, n2, ans, ansc;
- float start, t1, t2;
- srand(time(NULL));
- n1=rand()%49+51;
- n2=rand()%49+51;
- ansc=n1+n2;
- start=clock();
- cout<<n1<<" + "<<n2<<" = ";
- t1=clock()-start;
- cin>>ans;
- if(ans==ansc)
- cout<<"答對了! 本題花費"<<clock()-t1<<"毫秒思考!"<<endl;
- else
- cout<<"答錯了! 本題花費"<<clock()-t1<<"毫秒思考!"<<endl;
- system("pause");
- return 0;
- }
複製代碼 |