- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int e=0;
- re:
- srand(time(NULL));
- int a,b,c,d;
- a=rand()%49+51;
- b=rand()%49+51;
- c=a+b;
- cout<<a<<"+"<<b<<"=";
- long f,g,h;
- f=clock();
- cin>>d;
- g=clock();
- h=-(f-g);
- if(c==d)
- {
- cout<<"答對了,這題花了"<<h<<"毫秒"<<endl;
- e++;
- if(e==2)
- goto bye;
- goto re;
- }
- else
- {
- cout<<"答錯了,這題花了"<<h<<"毫秒"<<endl;
- e++;
- if(e==2)
- goto bye;
- goto re;
- }
- bye:
- system("pause");
- return 0;
- }
複製代碼 |