陰間東西
#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<<"按任意鍵繼續(xù)"<<endl;
x=getch();??
while(1)
{
system("cls");?
cout<<"選擇難度"<<endl<<"========================================================"<<endl<<"1.基礎(chǔ)"<<endl<<"2.一般"<<endl<<"3.進(jìn)階"<<endl<<"4.退出"<<endl;
? ? ? ? cin>>choice;?
switch(choice)
{
? ? case 1:
? ? while(count!=50)
? ? {
? ? system("cls");?
? ? cout<<"正確率:"<<accuracy<<"%"<<endl<<"進(jìn)度:"<<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<<"恭喜,訓(xùn)練結(jié)束!"<<endl;
cout<<"您的正確率為:"<<accuracy<<"%"<<endl<<"還請再接再厲!"<<endl;
cout<<"按任意鍵繼續(xù)"<<endl;
x=getch();?
? ? break;
? ? case 2:
? ? while(count!=50)
? ? {
? ? system("cls");?
? ? cout<<"正確率:"<<accuracy<<"%"<<endl<<"進(jìn)度:"<<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<<"恭喜,訓(xùn)練結(jié)束!"<<endl;
cout<<"您的正確率為:"<<accuracy<<"%"<<endl<<"還請再接再厲!"<<endl;
cout<<"按任意鍵繼續(xù)"<<endl;
x=getch();
? ? break;
? ? case 3:
? ? while(count!=50)
? ? {
? ? system("cls");?
? ? cout<<"正確率:"<<accuracy<<"%"<<endl<<"進(jìn)度:"<<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<<"恭喜,訓(xùn)練結(jié)束!"<<endl;
cout<<"您的正確率為:"<<accuracy<<"%"<<endl<<"還請再接再厲!"<<endl;
cout<<"按任意鍵繼續(xù)"<<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;
}?