#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
  srand((int)time(0));
  int input;  
  do
  {
    int rand1 = (rand() % 9) + 1;
    int rand2 = (rand() % 9) + 1;
    int com_answer = (rand1 * rand2), your_answer;
    cout << "======================" << endl;
    cout << "1.進行測驗." << endl;
    cout << "2.離開本程式." << endl;
    cout << "======================" << endl;
    cout << "請輸入您的選項:";
    cin >> input;
    switch( input )
    {
      case 1:
        do
        {
          cout << "How much is " << rand1 << " times " << rand2 << " ?";
          cin >> your_answer;
          if( com_answer != your_answer )
            cout << "不,請再一次" << endl;
          else
            cout << "非常好" << endl;
        } while( com_answer != your_answer );
        break;
      case 2:
        cout << "Thanks for your coming." << endl;
        break;
      default:
        cout << "Please input 1-2, thanks." << endl;
        break;
    }
  } while( input != 2 );
 
 
  return 0;
}

 

/*
Windows ,標頭檔再加上
#include <time.h>
即可。

 */

arrow
arrow
    全站熱搜

    Walter Blyss 發表在 痞客邦 留言(4) 人氣()