- #include<iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- int main()
- {
- int x,y,z;
- srand(time(NULL));
- x=rand()%49+51;
- y=rand()%49+51;
- cout<<x<<"+"<<y<<"=";
- cin>>z;
- if(z == x+y)
- {
- cout<<"恭喜答對!本題花了"<<clock()<<"毫秒思考!"<<endl;
- }else
- {
- cout<<"答錯囉,答案是:"<<x+y<<"本題花了"<<clock()<<"毫秒思考!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |