阴间东西
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<time.h>
#include<conio.h>
using namespace std;
int main()
{
int choice;
int i=0;
double count=0.0;
double right=0.0;
double accuracy=0.0;
char x;
char a[33]={'a','s','d','f','g','h','j','k','l',';','"','q','w','e','r','t','y','u','i','o','p','[',']','z','x','c','v','b','n','m',',','.'};
while(1)
{
cout<<"莫名其妙的打字游戏"<<endl<<"========================================================"<<endl<<"按任意键继续"<<endl;
x=getch();
while(1)
{
system("cls");
cout<<"选择难度"<<endl<<"========================================================"<<endl<<"1.基础"<<endl<<"2.一般"<<endl<<"3.进阶"<<endl<<"4.退出"<<endl;
cin>>choice;
switch(choice)
{
case 1:
while(count!=50)
{
system("cls");
cout<<"正确率:"<<accuracy<<"%"<<endl<<"进度:"<<count*2<<"%"<<endl<<"========================================================"<<endl;
srand(time(0));
i=rand()%(10)+0;
cout<<a[i]<<endl;
x=getch();
if(x==a[i])
{
cout<<"正确"<<endl;
right+=1;
}
else
{
cout<<"错误"<<endl;
}
count++;
accuracy=(right/count)*100;
}
system("cls");
cout<<"恭喜,训练结束!"<<endl;
cout<<"您的正确率为:"<<accuracy<<"%"<<endl<<"还请再接再厉!"<<endl;
cout<<"按任意键继续"<<endl;
x=getch();
break;
case 2:
while(count!=50)
{
system("cls");
cout<<"正确率:"<<accuracy<<"%"<<endl<<"进度:"<<count*2<<"%"<<endl<<"========================================================"<<endl;
srand(time(0));
i=rand()%(22)+0;
cout<<a[i]<<endl;
x=getch();
if(x==a[i])
{
cout<<"正确"<<endl;
right++;
}
else
{
cout<<"错误"<<endl;
}
count++;
accuracy=(right/count)*100;
}
system("cls");
cout<<"恭喜,训练结束!"<<endl;
cout<<"您的正确率为:"<<accuracy<<"%"<<endl<<"还请再接再厉!"<<endl;
cout<<"按任意键继续"<<endl;
x=getch();
break;
case 3:
while(count!=50)
{
system("cls");
cout<<"正确率:"<<accuracy<<"%"<<endl<<"进度:"<<count*2<<"%"<<endl<<"========================================================"<<endl;
srand(time(0));
i=rand()%(32)+0;
cout<<a[i]<<endl;
x=getch();
if(x==a[i])
{
cout<<"正确"<<endl;
right++;
}
else
{
cout<<"错误"<<endl;
}
count++;
accuracy=(right/count)*100;
}
system("cls");
cout<<"恭喜,训练结束!"<<endl;
cout<<"您的正确率为:"<<accuracy<<"%"<<endl<<"还请再接再厉!"<<endl;
cout<<"按任意键继续"<<endl;
x=getch();
break;
case 4:
system("cls");
cout<<"确定退出吗?"<<endl<<"1.是"<<" "<<"2.否"<<endl;
cin>>choice;
if(choice==1)
{
system("cls");
return 0;
}
else
{
break;
}
}
}
}
return 0;
}