#include <bits/stdc++.h>
#include <windows.h>
#include <fstream>
#include <conio.h>
using namespace std;
int Rand(int MIN, int MAX){
return rand() % (MAX - MIN + 1) + MIN;
}
void f(){
int my1=1,my2=1,he1=1,he2=1;
while(1){
system("cls");
cout << he1 << " " << he2 << "\n\n";
cout << my1 << " " << my2 << "\n";
cout << "\nmyWho:";
int g=_getch();
cout << "\nmygoto:";
int g1=_getch();
if(g=='1'&&my1!=0){
if(g1=='1'&&he1!=0){
my1=(my1+he1)%10;
}
else if(g1=='2'&&he2!=0){
my1=(my1+he2)%10;
}
}
else if(g=='2'&&my2!=0){
if(g1=='1'&&he1!=0){
my2=(my2+he1)%10;
}
else if(g1=='2'&&he2!=0){
my2=(my2+he2)%10;
}
}
if(my1==0&&my2==0){
Sleep(1000);
system("cls");
cout << "Win";
Sleep(1000);
system("cls");
return;
}
system("cls");
cout << he1 << " " << he2 << "\n\n";
cout << my1 << " " << my2 << "\n";
cout << "\nheWho:";
int r=Rand(1,2);
if(r==1&&he1==0){
r=2;
}
else if(r==2&&he2==0){
r=1;
}
if(he1+my1==10||he1+my2==10){
r=1;
}
else if(he2+my1==10||he2+my2==10){
r=2;
}
cout << r;
Sleep(1000);
cout << "\nhegoto:";
int r1=Rand(1,2);
if(r1==1&&my1==0){
r1=2;
}
else if(r1==2&&my2==0){
r1=1;
}
if(r==1){
if(he1+my1==10){
r1=1;
}
else if(he1+my2==10){
r1=2;
}
}
if(r==2){
if(he2+my1==10){
r1=1;
}
else if(he2+my2==10){
r1=2;
}
}
cout << r1;
Sleep(1000);
if(r==1){
if(r1==1){
he1=(he1+my1)%10;
}
else if(r1==2){
he1=(he1+my2)%10;
}
}
else if(r==2){
if(r1==1){
he2=(he2+my1)%10;
}
else if(r1==2){
he2=(he2+my2)%10;
}
}
if(he1==0&&he2==0){
system("cls");
cout << "HE WIN";
Sleep(1000);
system("cls");
return;
}
}
}
int main(){
int time=0;
ifstream AAAi;
AAAi.open("AAA.txt");
AAAi>>time;
time++;
srand(time);
int n;
cout << "次数:::";
cin >> n;
system("cls");
for(int i=0;i<n;i++){
f();
}
ofstream AAA;
AAA.open("AAA.txt");
AAA<<time<<" ";
return 0;
}
C++::1+1游戏
最新推荐文章于 2024-08-19 16:28:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)