Question:以"求给定两整数和"为题,要求应试者从键盘输入一个数作为答案,然后由程序给出正确与否的评判
//MathTest version_1.cpp
//Question:show u x+y and u input the answer program will judge if u r right or not
#include <iostream>
#include <ctime>
using namespace std;
int main(){
while(1){
int x,y,z,ans;
srand((unsigned)time(0));
x = rand()%100;
y = rand()%100;
ans = x + y;
cout << x << " + " << y << " = ";
cin >> z;
if(z == ans)
cout << "U R RIGHT:)" << endl;
else
cout << "THAT'S WRONG:( \nTRY AGAIN~" << endl;
}
return 0;
}
一周没写代码又开始小错不断╮(╯_╰)╭不进则退啊
又复习了一下随机数的写法, 不过时间种子怎么回事其实还是只知其然不知所以然...