#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
string To_Str(int);
string To_English(int);
int To_int(string);
void say();
void say2();
void Input_illegal();
void Loading();
void Egg();
char Create_Formula(int);
//声明函数
int First_Num,Second_Num,Right_Answer;
int Quantity,Scope,Input_Num;
int Right=0,Wrong=0;
string ass;
string num[30]={"one","two","three","four","five","six","seven","eight","nine","ten"\
,"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen"\
,"eighteen","nineteen","twenty","thirty","forty","fifty","sixty","seventy"\
,"eighty","ninety"};
string To_English(int number)
{
if (number>=100) return To_Str(number);
if (number<=20) return num[number-1];
string out;
out=out+"-"+num[number%10-1];
out=num[(number-number%10)/10+17]+out;
return out;
}
int To_Int(string number)
{
int Int=atoi(number.c_str());
return Int;
}
string To_Str(int number)
{
stringstream ss;
ss<<number;
string Str=ss.str();
return Str;
}
inline void say(string s)
{
for(int i=0;i<s.size();i++)
{
cout<<s[i];
Sleep(20);
}
printf("\n");
return;
}
inline void say2(string s)
{
for(int i=0;i<s.size();i++)
{
cout<<s[i];
Sleep(20);
}
return;
}
inline void Input_illegal()
{
say("Your input is illegal!");
Sleep(400);
say("The system has exited!");
Sleep(2000);
return;
}
inline void Egg()
{
say("Your input is illegal!");
Sleep(400);
say("The system has not exited!");
Sleep(2000);
say("Ha,ha!");
Sleep(400);
say("That's the egg!");
Sleep(1000);
say("The writer is henry!");
Sleep(2000);
return;
}
inline void Loading()
{
for (int i=1;i<=8;i++)
{
system("cls");
cout<<"Your computing career is over!"<<endl;
cout<<"Loading.";
Sleep(20);
system("cls");
cout<<"Your computing career is over!"<<endl;
cout<<"Loading..";
Sleep(20);
system("cls");
cout<<"Your computing career is over!"<<endl;
cout<<"Loading...";
Sleep(20);
}
system("cls");
return;
}
char Create_Formula(int Scope)
{
char Sign;
ReStart:
srand(time(0));
if (Scope>10)
{
First_Num=rand()%Scope;
Second_Num=rand()%Scope;
}
else
{
Second_Num=rand()%(Scope-1);
First_Num=rand()%(Scope-Second_Num-1)+Second_Num+1;
}
if (First_Num==Second_Num) goto ReStart;
Sign=(rand()%2==0)?'+':'-';
Sleep(30);
if (Sign=='+') Right_Answer=First_Num+Second_Num;
else Right_Answer=First_Num-Second_Num;
return Sign;
}
int main()
{
say("Hello!");
Sleep(500);
say("I am a interesting system of mental arithmetic.");
Sleep(500);
say("My name is Little Qi.");
Sleep(800);
cout<<endl;
say("Please don't type anything before I ask you.");
Sleep(1500);
bool Is_Yes;
if (MessageBox(NULL,TEXT("Are you good at Math?"),TEXT("Remember your choice"),MB_YESNO)==IDYES)
{
system("cls");
say("Are you sure?");
say("Let me put you to the test!");
Is_Yes=true;
}
else
{
system("cls");
say("Oh!");
say("Let me help you improve.");
Is_Yes=false;
}
if (MessageBox(NULL,TEXT("Can we get started?"),TEXT("Press the button!"),0))
{
Sleep(1500);
system("cls");
}
say("You can choose the difficulty now!");
say("Please choose the difficulty according to your own strength!");
Sleep(1000);
say("The first difficulty is simple. (Add and subtract within 10)");
Sleep(500);
say("The second difficulty is middle. (Add and subtract within 100)");
Sleep(500);
say("The third difficulty is difficult. (Add and subtract within 1000)");
Sleep(500);
say("The forth difficulty is inferno. (Add and subtract within 10000)");
Sleep(800);
say2("Please choose the difficulty:");
cin>>ass;
if (ass=="simple" or ass=="Simple" or ass=="1" or ass=="first" or ass=="First") Scope=10;
else if (ass=="middle" or ass=="Middle" or ass=="2" or ass=="second" or ass=="Second") Scope=100;
else if (ass=="difficult" or ass=="Difficult" or ass=="3" or ass=="third" or ass=="Third") Scope=1000;
else if (ass=="inferno" or ass=="Inferno" or ass=="4" or ass=="forth" or ass=="Forth") Scope=10000;
else if (ass=="helloworld!" or ass=="helloworld" or ass=="Hello world!" or ass=="Helloworld!"or ass=="Hello world")
{
Egg();
return 0;
}
else
{
Input_illegal();
return 0;
}
if (Scope==10)
{
say("You choose the simple difficulty.");
} else if (Scope==100)
{
say("You choose the middle difficulty.");
} else if (Scope==1000)
{
say("You choose the difficult dificulty.");
} else if (Scope==10000)
{
say("You choose the inferno dificulty.");
}
Sleep(1900);
say2("Please tell me how many crossings you need to make:");
cin>>ass;
for (int i=0;i<ass.size();i++)
{
if (ass[i]<='0'&&ass[i]>'9')
{
Input_illegal();
return 0;
}
}
Quantity=To_Int(ass);
if (Quantity<=0)
{
Input_illegal();
return 0;
}
if (Quantity>1) say("You're going to do "+To_English(Quantity)+" channel problems.");
else say("You're going to do one channel problem.");
Sleep(800);
say("Let's do the math!");
Sleep(1800);
system("cls");
for (int i=1;i<=Quantity;i++)
{
char Sign=Create_Formula(Scope);
cout<<First_Num<<Sign<<Second_Num<<'=';
cin>>ass;
for (int j=0;j<ass.size();j++)
{
if (ass[j]<'0'&&ass[j]>'9')
{
Input_illegal();
return 0;
}
}
Input_Num=To_Int(ass);
if (Input_Num==Right_Answer)
{
Right++;
say(" Your answer is correct!");
}
else
{
Wrong++;
say(" Your answer is wrong!");
}
Sleep(380);
if (i%5==0)
{
system("cls");
}
}
Sleep(850);
system("cls");
say("Your computing career is over!");
Loading();
if (Quantity>1) say("You've done "+To_English(Quantity)+" problems.");
else say("You've done "+To_English(Quantity)+" problem.");
if (Right>1) say("You've got "+To_English(Right)+" right answers!");
else say("You've got "+To_English(Right)+" right answer!");
if (Wrong>1) say("You've got "+To_English(Wrong)+" wrong answers!");
else say("You've got "+To_English(Wrong)+" wrong answer!");
//此处 if 语句判断的是英语中的单复数情况
float score=(100/Quantity)*Right;
if (score==0) say("You got a zero!");
else if (score<60) say("Your grades are failing.");
else if (score>=60 and score<80) say("Your grades are pass.");
else if (score>=80 and score<90) say("Your grades are good.");
else if (score>=90) say("Your grades are excellent.");
if (score>=90 and Is_Yes==true) say("You are really good at math!");
else if (score<60 and Is_Yes==true) say("Your Maths wasn't good, but you said you were good at math.");
else if (score>=90 and Is_Yes==false) say("Modesty is also a kind of strength!");
else if (score<60 and Is_Yes==false) say("Honesty is a good quality.");
Sleep(2000);
return 0;
}
共计312行