直接上代码:
#include<iostream>
#include<windows.h>
#include<conio.h>
using namespace std;
float score;
int blue,yellow,use=1;
int main() {
system("title 打字练习");
for(;;)
{
system("cls");
cout<<"欢迎来到打字练习!\n制作 | 老六工作室\n输入1打字\n输入2调整字颜色\n输入3退出\n输入4查看积分\n请输入:";
int t1;
cin>>t1;
if(t1==3)
{
system("cls");
MessageBox(0,"欢迎您下次使用!\n制作 | 老六工作室","再见",MB_OK);
return 0;
}
if(t1==4)
{
system("cls");
cout<<"您拥有 "<<score<<" 积分!\n按任意键返回...";
getch();
}
if(t1==2)
{
system("cls");
cout<<"白色(拥有)";
if(use==1)
cout<<"(使用中)";
cout<<"\n";
cout<<"蓝色";
if(blue==1)
cout<<"(拥有)";
if(use==2)
cout<<"(使用中)";
cout<<"\n";
cout<<"黄色";
if(yellow==1)
cout<<"(拥有)";
if(use==3)
cout<<"(使用中)";
cout<<"\n";
cout<<"操作:\n输入1 使用颜色\n输入2 使用积分购买颜色\n您的输入:";
int t2;
cin>>t2;
if(t2==2)
{
cout<<"操作:\n输入1 购买蓝色(50积分)\n输入2 购买黄色(100积分)\n您的输入:";
int t3;
cin>>t3;
if(t3==1)
if(score>=50)
{
score-=50;
blue=1;
MessageBox(0,"购买成功!","提示",MB_OK);
}
else MessageBox(0,"您的积分不足!","提示",MB_OK);
if(t3==2)
if(score>=100)
{
score-=100;
yellow=1;
MessageBox(0,"购买成功!","提示",MB_OK);
}
else MessageBox(0,"您的积分不足!","提示",MB_OK);
}
if(t2==1)
{
int t3;
cout<<"操作:\n输入1 使用蓝色\n输入2 使用黄色\n您的输入:";
cin>>t3;
if(t3==1&&blue==1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE);
if(t3==2&&yellow==1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED |FOREGROUND_GREEN);
}
}
if(t1==1)
{
cout<<"请选择难度\n输入1:26个字母(★)\n输入2:英文单词(★★)\n输入3:英文句子(★★★)\n输入4:英文短文(★★★★)\n输入5:乱码(★★★★★)\n您的输入:";
int t2;
cin>>t2;
if(t2==1)
{
cout<<"请输入a到z所有小写字母(例:abcd...xyz):\n";
string s;
cin>>s;
if(s=="abcdefghijklmnopqrstuvwxyz")
{
MessageBox(0,"打字正确!\n奖励2积分!","提示",MB_OK);
score+=2;
}
else
{
MessageBox(0,"打错字啦!\n0.5积分鼓励一下!","提示",MB_OK);
score+=0.5;
}
}
if(t2==2)
{
cout<<"请输入单词p h o t o g r a p h y(复制无效,输入时不能带空格):\n";
string s;
cin>>s;
if(s=="photography")
{
MessageBox(0,"打字正确!\n奖励3积分!","提示",MB_OK);
score+=3;
}
else
{
MessageBox(0,"打错字啦!\n0.6积分鼓励一下!","提示",MB_OK);
score+=0.6;
}
}
if(t2==3)
{
cout<<"请输入T r e e s c a n h e l p u s i n m a n y w a y s .这句话(复制无效,输入时不能带空格):\n";
string s;
cin>>s;
if(s=="Treescanhelpusinmanyways.")
{
MessageBox(0,"打字正确!\n奖励5积分!","提示",MB_OK);
score+=5;
}
else
{
MessageBox(0,"打错字啦!\n0.7积分鼓励一下!","提示",MB_OK);
score+=0.7;
}
}
if(t2==4)
{
cout<<"I g e t u p a t s e v e n i n t h e m o r n i n g .\nI h a v e l e s s o n s i n t h e m o r n i n g .\nT h e n I h a v e l u n c h .\nI p l a y i n t h e a f e r n o o n .\nI g o t o b e d a t n i n e .\n";
cout<<"请输入这篇短文(复制无效,输入时不能带空格):\n";
string s;
cin>>s;
if(s=="Igetupatseveninthemorning.Ihavelessonsinthemorning.ThenIhavelunch.Iplayintheafternoon.Igotobedatnine.")
{
MessageBox(0,"打字正确!\n奖励10积分!","提示",MB_OK);
score+=10;
}
else
{
MessageBox(0,"打错字啦!\n1积分鼓励一下!","提示",MB_OK);
score+=1;
}
}
if(t2==5)
{
cout<<"请输入 # $! @ #(*% ^&) @!^+* %$(&# ^# @@!)( & #@!@ (复制无效,输入时不能带空格):\n";
string s;
cin>>s;
if(s=="#$!@#(*%^&)@!^+*%$(&#^#@@!)(&#@!@")
{
MessageBox(0,"打字正确!\n奖励12积分!","提示",MB_OK);
score+=12;
}
else
{
MessageBox(0,"打错字啦!\n1.5积分鼓励一下!","提示",MB_OK);
score+=1.5;
}
}
}
}
return 0;
}
记得点赞哦!