C++#include<bits/stdc++.h>
using namespace std;
int cnt;
struct ti
{
double a,b,ans;
char fu;
}ct[100000];
string name;
double suan(int aa,char wow,int bb)
{
if(wow=='+') return aa+bb;
else if(wow=='-') return aa-bb;
else if(wow=='*') return aa*bb;
else if(wow=='/') return aa/bb;
}
void cuoti()
{
if(cnt==0)
{cout<<"您还没有错题哦\n\n";return ;}
else
{
int i=1;
while(1)
{
bool flag=0;
cout<<ct[i].a<<ct[i].fu<<ct[i].b<<"\n";
cout<<"您的答案是:"<<ct[i].ans<<"\n";
cout<<"正确答案是:"<<suan(ct[i].a,ct[i].fu,ct[i].b)<<"\n";
cout<<"页数:"<<i<<"/"<<cnt<<"\n";
cout<<"1.下一题\n";
cout<<"2.跳转\n";
cout<<"3.删除\n";
cout<<"4.退出\n";
int op;
while(1)
{
cin>>op;
if(op==1)
{
if(i==cnt) i=1;
else i++;
break;
}
else if(op==2)
{
cout<<"跳转至第几题:";
int ho;
cin>>ho;
if(ho<=cnt)i=ho;
break;
}
else if(op==3)
{
if(cnt>1)
{
for(int j=i;j<=cnt;j++) ct[j]=ct[j+1];
cnt--;
}
i=1;
break;
}
else if(op==4){flag=1;return ;}
}
}
}
}
void kousuan()
{
bool flag=0;
cout<<"您想算几题:";
int tishu,mod,jishu=1,haha;
cin>>tishu;
haha=tishu;
cout<<"选择难度(输入几即为 <=输入 的计算 例如:输入10为10以内计算):";
cin>>mod;
cout<<"您会计算负数吗:(是/否)";
string s;
cin>>s;
if(s=="是") flag=1;
while(tishu--)
{
int x=rand()%mod+1,y=rand()%mod+1,ha=rand()%4+1;
char hehe;
if(ha==1){hehe='+';}
else if(ha==2){hehe='-';}
else if(ha==3){hehe='*';}
else{hehe='/';}
if(hehe=='/'&&x%y!=0) hehe='+';
if(!flag&&hehe=='-'&&x-y<0) hehe='+';
double yans,zans=suan(x,hehe,y);
cout<<x<<hehe<<y<<"=";
cin>>yans;
if(yans!=zans)
{
cnt++;
ct[cnt].a=x;
ct[cnt].b=y;
ct[cnt].fu=hehe;
ct[cnt].ans=yans;
cout<<"oh no ,答错了呢,已加入错题本!\n";
}
else
{
cout<<"真棒!o(* ̄▽ ̄*)ブ\n";
}
cout<<"当前"<<jishu++<<"/"<<haha<<"\n";
}
}
void jisuanqi()
{
int x,y;
char fu;
cout<<"第一个数:";
cin>>x;
cout<<"第二个数:";
cin>>y;
cout<<"符号:";
cin>>fu;
cout<<x<<fu<<y<<"="<<suan(x,fu,y)<<"\n";
}
void kaishijiemian()
{
while(1)
{
cout<<"====================================\n";
cout<<"|尊敬的"<<name<<"欢迎来到大冤口算|\n";
cout<<"| 1.错题本 |\n";
cout<<"| 2.开始口算 |\n";
cout<<"| 3.大冤计算 |\n";
cout<<"| (输入数字开始) |\n";
cout<<"===================================\n";
int op;
cin>>op;
if(op==1){cuoti();}
else if(op==2){kousuan();}
else if(op==3){jisuanqi();}
else {cout<<"(╯▔皿▔)╯\n";kaishijiemian();}
}
}void denglu()
{
cout<<"用户您好,请输入您的昵称:";
cin>>name;
cout<<"是个很好听的名字呢\n";
kaishijiemian();
}
int main()
{
denglu();
return 0;
}