v2.0上线啦!!
先上代码:
#include<cstdio>
#include<ctime>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iostream>
#include<cmath>
#include<cstring>
#include<windows.h>
using namespace std;
const int N = 5010;
int n = 0;
int hard;
int x = 0, y = 0;
int res[N];
int a_[N];
int b_[N];
int yxcnb[N];
int test, c_ = -1;
void print(int x)
{
system("cls");
cout << "%" << x;
}
void made_in()
{
print(10);
if(hard == 1)
{
n += 10;
test = 1;
x += 20, y += 20;
c_ = 1;
hard = 3;
print(100);
return;
}
if(hard == 2)
{
n += 10;
test = -2;
x += 20, y += 20;
hard = 3;
print(100);
return;
}
print(20);
if(hard == 3)
{
n += 20;
test = -2;
x += 20, y += 20;
hard = 3;
print(100);
return;
}
if(hard == 4)
{
n += 20;
test = -1;
x += 25, y += 25;
hard = 4;
print(100);
return;
}
print(30);
if(hard == 5)
{
n += 30;
test += -2;
x += 100, y += 100;
hard = 5;
print(100);
return;
}
if(hard == 6)
{
n += 50;
test = -2;
x += 100, y += 100;
hard = 6;
print(100);
return;
}
print(40);
if(hard == 7)
{
n += 50;
test = -1;
x += 100, y += 100;
hard = 7;
print(100);
return;
}
if(hard == 8)
{
n += 100;
test = -1;
x += 100, y += 100;
hard = 8;
print(100);
return;
}
print(50);
if(hard == 9)
{
n += 100;
test = -1;
x += 500, y += 500;
hard = 9;
print(100);
return;
}
if(hard == 10)
{
n += 100;
test = -1;
x += 500, y += 500;
hard = 10;//emmmmmm,5秒一道500以内加减乘好像并不是很难 (((
print(100);
return;
}
print(60);
if(hard == -1)
{
print(70);
Sleep(1);
srand(clock());
int blah = rand() % 10000 + 1;
int qwq;
for(int i = 1; i <= 10000; i ++)
{
if(i % blah == 0)
{
blah += i;
if(blah >= 10000)
{
qwq = i;
break;
}
}
}
print(80);
srand(qwq);
n = rand() % qwq + 1;//等等,万一很不顺,qwq很大咋办(没事,后面有生成失败
srand(n);
x = rand() % n + 1;
srand(x);
y = rand() % x + 1;
srand(y);
y = rand() % x + 1;
//保险起见,多一次保险
srand(y);
hard = rand() % 10;//防止变态,不加1了。
print(90);
made_in();//你魔鬼啊:对,我魔鬼
print(100);
return;
}
else
{
print(100);
return;
}
}
int main()
{
cout << "请输入难度:(越大越难,1-10),如果想随机挑战,输入-1" << endl;
cin >> hard;
cout << "处理数据中:";
Sleep(5000);
int test, c_ = -1;
made_in();
cout << "正在生成中,请稍等。" << endl;
Sleep(1000);
system("cls");
if(x > 1000 || y > 1000)
{
cout << "生成失败" << endl;
Sleep(1000);
cout << "原因:数据范围过大。" << endl;
Sleep(2000);
return 0;
}
else if(n > 5000)//我觉得是不是应该改一改
{
cout << "生成失败" << endl;
Sleep(1000);
cout << "原因:生成时间过长,容易爆栈。" << endl;
Sleep(2000);
return 0;
}
else if(hard >= n - 1)
{
cout << "生成失败" << endl;
Sleep(1000);
cout << "原因:难度不科学" << endl;
Sleep(2000);
return 0;
}
else cout << "生成成功!程序退出后请在桌面中查看。" << endl;
if(n > 500)
{
n %= 1000;
if(n > 500)
{
n %= 500;
}
}
if(n > 200)
{
n %= 200;
}
//cout << endl;
//cout << "test:" << n << ' ' << hard << ' ' << x << ' ' << y << ' ';
freopen("D:\\吾爱刷题\\口算\\20200812.md", "w", stdout);
printf("# 今天的口算:\n");
cout << "# 请在 $ " << int(n / hard) << " $ 分钟内完成。" << endl;
cout << "## 习题" << endl;
for(int i = 0; i < n ;i ++)
{
Sleep(1);
srand(clock());
int a = rand() % x + 1;
Sleep(1);
srand(clock());
int b = rand() % y + 1;
Sleep(1);
int c;
a_[i] = a, b_[i] = b;
if(test == -1)
{
srand(clock());
c = rand() % 3 + 1;
Sleep(1);
}
else if(test == -2)
{
srand(clock());
c = rand() % 2 + 1;
Sleep(1);
}
else c = c_;
yxcnb[i] = c;
if(c == 1)
{
cout << "#### $ " << i + 1 << ": " << a;
cout << " + " << b;
res[i] = a + b;
cout << " = $" << endl;
}
if(c == 2)
{
cout << "#### $ " << i + 1 << ": " << a;
cout << " - " << b;
res[i] = a - b;
cout << " = $" << endl;
}
if(c == 3)
{
cout << "#### $ " << i + 1 << ": " << a;
cout << " × " << b;
res[i] = a * b;
cout << " = $" << endl;
}
}
cout << endl << "****" << endl;
cout << "## 答案" << endl;
for(int i = 0; i < n; i ++)
{
cout << "#### $ " << i + 1 << ": " << a_[i];
if(yxcnb[i] == 1) cout << " + ";
if(yxcnb[i] == 2) cout << " - ";
if(yxcnb[i] == 3) cout << " × ";
cout << b_[i] << " = " << res[i] << " $" << endl;
}
cout << endl;
fclose(stdout);
return 0;
}
收藏不亏!
这次为各位魔鬼玩家带来了魔鬼模式,按下-!-1!
然后还增加了自动调整难度功能!
以及答案功能~
考虑到各位的打印机,把3级标题改成了4级标题。
然后缩小了范围。
重要的事情说10遍:
orz,我来查bug
哈哈哈
我以为要写GUI界面呢
没有了
int yxcnb[N];
这个。。。哈哈哈哈哈哈哈23333
放个运行界面的图就更好了
hh谢谢y总指导
第一眼还以为y总要他写个图形化界面hhhh
hh
大佬可以试试啊
233333,只是感觉截个效果图会更吸引人。
呵呵呵/憨憨
自占前排