- #include<iostream>
- #include<ctime>
- using namespace std;
- int main(){
- srand(time(NULL));
- int a, b, ans, ans_c;
- a=rand()%49+51;
- b=rand()%49+51;
- ans_c=a+b;
- cout<<a<<"+"<<b<<"=";
- int start, end, pass;
- start=clock();
- cin>>ans;
- end=clock();
- pass=end-start;
- if(ans_c==ans){
- cout<<"答對了! 本題花了"<<pass<<"毫秒思考!\n";
- }
- else{
- cout<<"答錯了! 本題花了"<<pass<<"毫秒思考\n!";
- }
-
- system("pause");
- return 0;
- }
複製代碼 |