返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;

  5. int main()
  6. {
  7.     int e=0;
  8.     re:
  9.     srand(time(NULL));
  10.     int a,b,c,d;
  11.     a=rand()%49+51;
  12.     b=rand()%49+51;
  13.     c=a+b;
  14.     cout<<a<<"+"<<b<<"=";
  15.     long f,g,h;
  16.     f=clock();
  17.     cin>>d;        
  18.     g=clock();
  19.     h=-(f-g);
  20.     if(c==d)
  21.     {
  22.         cout<<"答對了,這題花了"<<h<<"毫秒"<<endl;
  23.         e++;
  24.         if(e==2)
  25.             goto bye;
  26.         goto re;
  27.     }
  28.     else
  29.     {
  30.         cout<<"答錯了,這題花了"<<h<<"毫秒"<<endl;
  31.         e++;
  32.         if(e==2)
  33.             goto bye;
  34.         goto re;
  35.     }
  36.     bye:
  37.     system("pause");
  38.     return 0;
  39. }
複製代碼

TOP

返回列表