简单的三子棋游戏

#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
#include<windows.h>
#include<string>
using namespace std;
int main(){
	char i,k;
	
	cout<<"     ================"<<endl;
	cout<<"     =====三子棋====="<<endl;
	cout<<"     ================"<<endl<<endl;
	cout<<"按任意键开始游戏"<<endl;
	string kaishi;
	cin>>kaishi;
	Sleep(1000); 
	cout<<"注意:黑先"<<endl;
	cout<<"q|w|e"<<endl;
	cout<<"-+-+-"<<endl; 
	cout<<"a|s|d"<<endl;
	cout<<"-+-+-"<<endl; 
	cout<<"z|x|c"<<endl;
	Sleep(2000);
	cout<<"游戏准备开始!"<<endl<<endl;
	Sleep(2000);
	while(1){
		GO:
		string q="无",w="无",e="无",a="无",s="无",d="无",z="无",x="无",c="无";
		int q1=0,w1=0,e1=0,a1=0,s1=0,d1=0,z1=0,x1=0,c1=0;
		int panduan=0,pd1=0;
		bool num=false,flag1=1;
		while(1){
			if(panduan==0){
				if(flag1){
					system("cls");
					flag1=0;
				}
				cout<<q<<"|"<<w<<"|"<<e<<endl;
				cout<<"--+--+--"<<endl;
				cout<<a<<"|"<<s<<"|"<<d<<endl;
				cout<<"--+--+--"<<endl;
				cout<<z<<"|"<<x<<"|"<<c<<endl<<endl;
			}
			if(q=="黑"&&w=="黑"&&e=="黑"||q=="黑"&&s=="黑"&&c=="黑"||q=="黑"&&a=="黑"&&z=="黑"||w=="黑"&&s=="黑"&&x=="黑"||a=="黑"&&s=="黑"&&d=="黑"||e=="黑"&&d=="黑"&&c=="黑"||e=="黑"&&s=="黑"&&z=="黑"||z=="黑"&&x=="黑"&&c=="黑"&&pd1==0){
				cout<<"黑棋胜!!!"<<endl;
				pd1=1;
				Sleep(1000);
			}else if(q=="白"&&w=="白"&&e=="白"||q=="白"&&s=="白"&&c=="白"||q=="白"&&a=="白"&&z=="白"||w=="白"&&s=="白"&&x=="白"||a=="白"&&s=="白"&&d=="白"||e=="白"&&d=="白"&&c=="白"||e=="白"&&s=="白"&&z=="白"||z=="白"&&x=="白"&&c=="白"&&pd1==0){
				cout<<"白棋胜!!!"<<endl;
				pd1=1;
				Sleep(1000);
			}else if(q1==1&&w1==1&&e1==1&&a1==1&&s1==1&&d1==1&&z1==1&&x1==1&&c1==1&&pd1==0){
				cout<<"平局"<<endl;
				pd1=1;
				Sleep(1000);
			}
			if(pd1==1){
				cout<<"是否继续?(y/n)"<<endl;
				string flag;
				while(1){
					cin>>flag;
					if(flag=="y"){
						cout<<"游戏准备开始!"<<endl<<endl;
						Sleep(2000);
						system("cls");
						goto GO;
						
					}else if(flag=="n") return 0;
					else cout<<"请在输入一次"<<endl; 
				}	
			} 
			cin>>i;
			panduan=0;
			if(i=='q'&&q1==0){
				if(num==false){
					q="黑";
					num=true;
					q1++;
				}else{
					q="白";
					num=false;
					q1++;
				}
				flag1=1;
			}else if(i=='w'&&w1==0){
				if(num==false){
					w="黑";
					num=true;
					w1++; 
				}else{
					w="白";
					num=false;
					w1++;
				}
				flag1=1;
			}else if(i=='e'&&e1==0){
				if(num==false){
					e="黑";
					num=true;
					e1++;
				}else{
					e="白";
					num=false;
					e1++;
				}
				flag1=1;
			}else if(i=='a'&&a1==0){
				if(num==false){
					a="黑";
					num=true; 
					a1++;
				}else{
					a="白";
					num=false;
					a1++;
				}
				flag1=1;
			}else if(i=='s'&&s1==0){
				if(num==false){
					s="黑";
					num=true; 
					s1++;
				}else{
					s="白";
					num=false;
					s1++;
				}
				flag1=1;
			}else if(i=='d'&&d1==0){
				if(num==false){
					d="黑";
					num=true; 
					d1++;
				}else{
					d="白";
					num=false;
					d1++;
				}
				flag1=1;
			}else if(i=='z'&&z1==0){
				if(num==false){
					z="黑";
					num=true; 
					z1++;
				}else{
					z="白";
					num=false;
					z1++;
				}
				flag1=1;
			}else if(i=='x'&&x1==0){
				if(num==false){
					x="黑";
					num=true; 
					x1++;
				}else{
					x="白";
					num=false;
					x1++;
				}
				flag1=1;
			}else if(i=='c'&&c1==0){
				if(num==false){
					c="黑";
					num=true; 
					c1++;
				}else{
					c="白";
					num=false;
					c1++;
				}
				flag1=1;
			}else{
				cout<<"请在输入一次"<<endl; 
				panduan=1;
			}
		}
	} 
	
	return 0;
}

#include<iostream>
#include<bits/stdc++.h>
#include<cstring>
#include<windows.h>
#include<string>
using namespace std;
int main(){
    char i,k;
    
    cout<<"     ================"<<endl;
    cout<<"     =====三子棋====="<<endl;
    cout<<"     ================"<<endl<<endl;
    cout<<"按任意键开始游戏"<<endl;
    string kaishi;
    cin>>kaishi;
    Sleep(1000); 
    cout<<"注意:黑先"<<endl;
    cout<<"q|w|e"<<endl;
    cout<<"-+-+-"<<endl; 
    cout<<"a|s|d"<<endl;
    cout<<"-+-+-"<<endl; 
    cout<<"z|x|c"<<endl;
    Sleep(2000);
    cout<<"游戏准备开始!"<<endl<<endl;
    Sleep(2000);
    while(1){
        GO:
        string q="无",w="无",e="无",a="无",s="无",d="无",z="无",x="无",c="无";
        int q1=0,w1=0,e1=0,a1=0,s1=0,d1=0,z1=0,x1=0,c1=0;
        int panduan=0,pd1=0;
        bool num=false,flag1=1;
        while(1){
            if(panduan==0){
                if(flag1){
                    system("cls");
                    flag1=0;
                }
                cout<<q<<"|"<<w<<"|"<<e<<endl;
                cout<<"--+--+--"<<endl;
                cout<<a<<"|"<<s<<"|"<<d<<endl;
                cout<<"--+--+--"<<endl;
                cout<<z<<"|"<<x<<"|"<<c<<endl<<endl;
            }
            if(q=="黑"&&w=="黑"&&e=="黑"||q=="黑"&&s=="黑"&&c=="黑"||q=="黑"&&a=="黑"&&z=="黑"||w=="黑"&&s=="黑"&&x=="黑"||a=="黑"&&s=="黑"&&d=="黑"||e=="黑"&&d=="黑"&&c=="黑"||e=="黑"&&s=="黑"&&z=="黑"||z=="黑"&&x=="黑"&&c=="黑"&&pd1==0){
                cout<<"黑棋胜!!!"<<endl;
                pd1=1;
                Sleep(1000);
            }else if(q=="白"&&w=="白"&&e=="白"||q=="白"&&s=="白"&&c=="白"||q=="白"&&a=="白"&&z=="白"||w=="白"&&s=="白"&&x=="白"||a=="白"&&s=="白"&&d=="白"||e=="白"&&d=="白"&&c=="白"||e=="白"&&s=="白"&&z=="白"||z=="白"&&x=="白"&&c=="白"&&pd1==0){
                cout<<"白棋胜!!!"<<endl;
                pd1=1;
                Sleep(1000);
            }else if(q1==1&&w1==1&&e1==1&&a1==1&&s1==1&&d1==1&&z1==1&&x1==1&&c1==1&&pd1==0){
                cout<<"平局"<<endl;
                pd1=1;
                Sleep(1000);
            }
            if(pd1==1){
                cout<<"是否继续?(y/n)"<<endl;
                string flag;
                while(1){
                    cin>>flag;
                    if(flag=="y"){
                        cout<<"游戏准备开始!"<<endl<<endl;
                        Sleep(2000);
                        system("cls");
                        goto GO;
                        
                    }else if(flag=="n") return 0;
                    else cout<<"请在输入一次"<<endl; 
                }    
            } 
            cin>>i;
            panduan=0;
            if(i=='q'&&q1==0){
                if(num==false){
                    q="黑";
                    num=true;
                    q1++;
                }else{
                    q="白";
                    num=false;
                    q1++;
                }
                flag1=1;
            }else if(i=='w'&&w1==0){
                if(num==false){
                    w="黑";
                    num=true;
                    w1++; 
                }else{
                    w="白";
                    num=false;
                    w1++;
                }
                flag1=1;
            }else if(i=='e'&&e1==0){
                if(num==false){
                    e="黑";
                    num=true;
                    e1++;
                }else{
                    e="白";
                    num=false;
                    e1++;
                }
                flag1=1;
            }else if(i=='a'&&a1==0){
                if(num==false){
                    a="黑";
                    num=true; 
                    a1++;
                }else{
                    a="白";
                    num=false;
                    a1++;
                }
                flag1=1;
            }else if(i=='s'&&s1==0){
                if(num==false){
                    s="黑";
                    num=true; 
                    s1++;
                }else{
                    s="白";
                    num=false;
                    s1++;
                }
                flag1=1;
            }else if(i=='d'&&d1==0){
                if(num==false){
                    d="黑";
                    num=true; 
                    d1++;
                }else{
                    d="白";
                    num=false;
                    d1++;
                }
                flag1=1;
            }else if(i=='z'&&z1==0){
                if(num==false){
                    z="黑";
                    num=true; 
                    z1++;
                }else{
                    z="白";
                    num=false;
                    z1++;
                }
                flag1=1;
            }else if(i=='x'&&x1==0){
                if(num==false){
                    x="黑";
                    num=true; 
                    x1++;
                }else{
                    x="白";
                    num=false;
                    x1++;
                }
                flag1=1;
            }else if(i=='c'&&c1==0){
                if(num==false){
                    c="黑";
                    num=true; 
                    c1++;
                }else{
                    c="白";
                    num=false;
                    c1++;
                }
                flag1=1;
            }else{
                cout<<"请在输入一次"<<endl; 
                panduan=1;
            }
        }
    } 
    
    return 0;
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值