本次更新追加了加减乘除的计算,但是成绩计算功能暂时还没有完成。。。
200行代码,好好好这么玩是吧?
#include <iostream>
using namespace std;
int random(int theseed);//随机数函数
int shiwei(int x);//取十位数字
int gewei(int x);//取个位数字
int main()
{
int s1,s2;
int d;//难度
int daan;//答案
cout << "输入两个种子:";
cin >> s1>>s2;
int shi1 =shiwei( random(s1));
int shi2 =shiwei( random(s2));
int ge1 =gewei(shi1);
int ge2 =gewei(shi2);
cout << "输入难度等级:一级难度只用 1 位数(输入1),二级难度用 2 位数(输入2);"<<endl;
cin >> d;
if (d == 1)
{
cout << ge1 << "+" << ge2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == ge1 + ge2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为"<<ge1+ge2;
}
}
if (d == 2)
{
cout << shi1 << "+" << shi2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == shi1 + shi2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为:"<<shi1+shi2;
}
}
cout << "接下来进行减法" << endl;
if (d == 1)
{
cout << ge1 << "-" << ge2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == ge1 - ge2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为" << ge1 - ge2;
}
}
if (d == 2)
{
cout << shi1 << "+" << shi2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == shi1 - shi2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为:" << shi1 - shi2;
}
}
cout << "接下来进行乘法" << endl;
if (d == 1)
{
cout << ge1 << "*" << ge2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == ge1 * ge2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为" << ge1 * ge2;
}
}
if (d == 2)
{
cout << shi1 << "*" << shi2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == shi1 * shi2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为:" << shi1 - shi2;
}
}
cout << "接下来进行除法" << endl;
if (d == 1)
{
cout << ge1 << "/" << ge2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == ge1 / ge2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为" << ge1 / ge2;
}
}
if (d == 2)
{
cout << shi1 << "/" << shi2 << "= ?" << endl;
cout << "你的答案是?";
cin >> daan;
if (daan == shi1 / shi2)
{
cout << "回答正确!";
}
else
{
cout << "回答错误,正确答案为:" << shi1 / shi2;
}
}
return 0;
}
int shiwei(int x)
{
int shi;
shi = x % 100; // 直接取x除以100的余数即可得到后两位
return shi;
}
int gewei(int x)
{
int ge;
ge = x % 10; // 直接取x除以10的余数即可得到后一位
return ge;
}
int random(int theseed)
{
static int rk = theseed;
int rk2;
rk2 = (25173 * rk + 13849) % 65536;
rk = rk2;
return rk2;
}