- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int num1, num2;
- int in,wer;
- srand(time(NULL));
- num1 = rand() % 48 + 51;
- num2 = rand() % 48 + 51;
- wer = num1 + num2;
- cout << num1 << " + " << num2 << " = ?" << endl;
- cin >> in;
- if (in != wer)
- cout << "答錯了!本題花了" << clock() << "毫秒的時間思考" << endl;
- else
- cout<< "答對了!本題花了" << clock() << "毫秒的時間思考" << endl;
- system("pause");
- system("cls");
- return 0;
- }
複製代碼 |