- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int a,b,c1,c2;
- srand(time(NULL));
- a=rand()%49+51;
- b=rand()%49+51;
- c1=a+b;
- long d1,d2;
- cout<<a<<"+"<<b<<"=";
- d1=clock();
- cin>>c2;
- d2=clock();
- if(c1==c2)
- {
- cout<<"答對了! 你花了"<<clock()<<"毫秒!"<<endl;
- }
- if(c1!=c2)
- {
- cout<<"答錯了! 你花了"<<clock()<<"毫秒!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |