#include
#include
#include
#include
const int STEP=8;
const int N=4;
int a[N],b[N],xxx,yyy,step;
using namespace std;
void main1(){
srand(time(0));
for(int i=0;i
a[i]=rand()%10;
for(int j=0;j
if(a[j]==a[i]){
i--;break;
}
}
}
return;
}
int main2(){
int n;
xxx=0,yyy=0;
cin>>n;
for(int i=0;i
b[i]=n%10;
n/=10;
}
for(int i=0;i
if(a[i]==b[i]){
xxx++;
}
else{
for(int j=0;j
yyy++;
}
}
//输出
cout<<"你猜的结果是:";
cout<
}
bool win(){
if(xxx==N){
cout<<"恭喜你,猜对了!!!";
return 1;
}
else{
return 0;
}
}
bool lose(){
if(step==8){
cout<<"次数用完,游戏失败!!!n";
return 1;
}
else{
cout<<"你还有"<
}
}
int main(){
SetConsoleTitle("Rickey的猜数字游戏");
main1();
while(1){
main2();
step++;
if(win()){
break;
}
if(lose()){
break;
}
}
cout<<"是否继续游戏?n";
cout<<"输入1继续,其他退出!n";
char ch;
cin>>ch;
if(ch=='1'){
system("cls");
step=0;
main();
}
else{
cout<<"欢迎下次游戏!";
}
return 0;
}



