0
已解决
#include<iostream>
#include<conio.h>
#include<ctime>
#include<bits/stdc++.h>
using namespace std;
int main(){
char ji='a',ren,a;
double min=10000000000000000000000000;
clock_t ks,js;
while(true){
srand(time(NULL));
ji='a'+rand()%26;
cout<<"请照着输入:"<<endl;
cout<<ji<<endl;
ks=clock();
do{
ren=getch();
cout<<ren;
if(ren!=ji){
cout<<'\b';
}
}while(ji!=ren);
js=clock();
cout<<endl<<"恭喜您,用了"<<(double)(js-ks)/CLOCKS_PER_SEC<<"秒"<<endl;
if((double)(js-ks)/CLOCKS_PER_SEC<=min){
min=(double)(js-ks)/CLOCKS_PER_SEC;
}
cout<<"请问还玩不玩,继续按f,退出按j"<<endl;
cin>>a;
if(a=='f'){
cout<<"继续吧"<<endl;
}
if(a=='j'){
cout<<"你的最好成绩为"<<min<<"秒,下次再来吧!";
return 0;
}
}
return 0;
}
