五子棋(1.0)

最近想玩一玩五子棋,就自己做了一个

现在只能玩双人的。。。

上代码:

#ifndef SOMETHING_H
#define SOMETHING_H
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
void ycgb() {
	CONSOLE_CURSOR_INFO cursor;
	cursor.bVisible = FALSE;
	cursor.dwSize = sizeof(cursor);
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorInfo(handle, &cursor);
	return ;
}
#endif
using namespace std;
int s[20][20]= {0};
int a,b,c;
void show() {
	memset(s,0,sizeof s);
	cout<<"先行再列!"<<endl;
	cout<<"   0 1 2 3 4 5 6 7 8 9 10"<<endl;
	for(int y=0; y<=9; y++)
		cout<<y<<"  - - - - - - - - - - -"<<endl;
	cout<<"10"<<" - - - - - - - - - - -"<<endl;
}
int main() {
	system("mode con cols=31 lines=15");
	ycgb();
	show();
	while(1) {
		cout<<"1P:";
		cin>>a;
		cout<<"1P:";
		cin>>b;
		
		if(s[a][b]!=0) {
			do {
				cout<<"已存在,请重新输入:"<<endl;
				system("cls");
				cout<<"先行再列!"<<endl;
				cout<<"   0 1 2 3 4 5 6 7 8 9 10"<<endl;
				for(int i=0; i<10; i++) {
					cout<<i<<"  ";
					for(int j=0; j<11; j++) {
						if(s[i][j]==0) cout<<"- ";
						else cout<<s[i][j]<<" ";
					}
					cout<<endl;
				}
				cout<<"10 ";
				for(int j=0; j<11; j++) {
					if(s[10][j]==0) cout<<"- ";
					else cout<<s[10][j]<<" ";
				}
				cout<<endl;
				cout<<"2P:";
				cin>>a;
				cout<<"2P:";
				cin>>b;
			} while(s[a][b]!=0);
		}
		s[a][b]=1;
		system("cls");
		cout<<"先行再列!"<<endl;
		cout<<"   0 1 2 3 4 5 6 7 8 9 10"<<endl;
		for(int i=0; i<10; i++) {
			cout<<i<<"  ";
			for(int j=0; j<11; j++) {
				if(s[i][j]==0) cout<<"- ";
				else cout<<s[i][j]<<" ";
			}
			cout<<endl;
		}
		cout<<"10 ";
		for(int j=0; j<11; j++) {
			if(s[10][j]==0) cout<<"- ";
			else cout<<s[10][j]<<" ";
		}
		cout<<endl;
		if(s[a][b]==1&&s[a-1][b+1]==1&&s[a-2][b+2]==1&&s[a-3][b+3]==1&&s[a-4][b+4]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a+1][b-1]==1&&s[a-1][b+1]==1&&s[a-2][b+2]==1&&s[a-3][b+3]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a+1][b-1]==1&&s[a+2][b-2]==1&&s[a-1][b+1]==1&&s[a-2][b+2]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a+1][b-1]==1&&s[a+2][b-2]==1&&s[a+3][b-3]==1&&s[a-1][b+1]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a+1][b-1]==1&&s[a+2][b-2]==1&&s[a+3][b-3]==1&&s[a+4][b-4]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a+1][b+1]==1&&s[a+2][b+2]==1&&s[a+3][b+3]==1&&s[a+4][b+4]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b-1]==1&&s[a+1][b+1]==1&&s[a+2][b+2]==1&&s[a+3][b+3]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b-1]==1&&s[a-2][b-2]==1&&s[a+1][b+1]==1&&s[a+2][b+2]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b-1]==1&&s[a-2][b-2]==1&&s[a-3][b-3]==1&&s[a+1][b+1]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b-1]==1&&s[a-2][b-2]==1&&s[a-3][b-3]==1&&s[a-4][b-4]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a+1][b]==1&&s[a+2][b]==1&&s[a+3][b]==1&&s[a+4][b]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b]==1&&s[a+1][b]==1&&s[a+2][b]==1&&s[a+3][b]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b]==1&&s[a-2][b]==1&&s[a+1][b]==1&&s[a+2][b]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b]==1&&s[a-2][b]==1&&s[a-3][b]==1&&s[a+1][b]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a-1][b]==1&&s[a-2][b]==1&&s[a-3][b]==1&&s[a-4][b]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a][b+1]==1&&s[a][b+2]==1&&s[a][b+3]==1&&s[a][b+4]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a][b-1]==1&&s[a][b+1]==1&&s[a][b+2]==1&&s[a][b+3]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a][b-1]==1&&s[a][b-2]==1&&s[a][b+1]==1&&s[a][b+2]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a][b-1]==1&&s[a][b-2]==1&&s[a][b-3]==1&&s[a][b+1]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==1&&s[a][b-1]==1&&s[a][b-2]==1&&s[a][b-3]==1&&s[a][b-4]==1) {
			cout<<"1Pwin"<<endl;
			system("pause");
			return 0;
		}
		cout<<"2P:";
		cin>>a;
		cout<<"2P:";
		cin>>b;
		if(s[a][b]!=0) {
			do {
				cout<<"已存在,请重新输入:"<<endl;
				system("cls");
				cout<<"先行再列!"<<endl;
				cout<<"   0 1 2 3 4 5 6 7 8 9 10"<<endl;
				for(int i=0; i<10; i++) {
					cout<<i<<"  ";
					for(int j=0; j<11; j++) {
						if(s[i][j]==0) cout<<"- ";
						else cout<<s[i][j]<<" ";
					}
					cout<<endl;
				}
				cout<<"10 ";
				for(int j=0; j<11; j++) {
					if(s[10][j]==0) cout<<"- ";
					else cout<<s[10][j]<<" ";
				}
				cout<<endl;
				cout<<"2P:";
				cin>>a;
				cout<<"2P:";
				cin>>b;
			} while(s[a][b]!=0);
		}
		s[a][b]=2;
		system("cls");
		cout<<"先行再列!"<<endl;
		cout<<"   0 1 2 3 4 5 6 7 8 9 10"<<endl;
		for(int i=0; i<10; i++) {
			cout<<i<<"  ";
			for(int j=0; j<11; j++) {
				if(s[i][j]==0) cout<<"- ";
				else cout<<s[i][j]<<" ";
			}
			cout<<endl;
		}
		cout<<"10 ";
		for(int j=0; j<11; j++) {
			if(s[10][j]==0) cout<<"- ";
			else cout<<s[10][j]<<" ";
		}
		cout<<endl;
		if(s[a][b]==2&&s[a-1][b+1]==2&&s[a-2][b+2]==2&&s[a-3][b+3]==2&&s[a-4][b+4]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a+1][b-1]==2&&s[a-1][b+1]==2&&s[a-2][b+2]==2&&s[a-3][b+3]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a+1][b-1]==2&&s[a+2][b-2]==2&&s[a-1][b+1]==2&&s[a-2][b+2]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a+1][b-1]==2&&s[a+2][b-2]==2&&s[a+3][b-3]==2&&s[a-1][b+1]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a+1][b-1]==2&&s[a+2][b-2]==2&&s[a+3][b-3]==2&&s[a+4][b-4]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a+1][b+1]==2&&s[a+2][b+2]==2&&s[a+3][b+3]==2&&s[a+4][b+4]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b-1]==2&&s[a+1][b+1]==2&&s[a+2][b+2]==2&&s[a+3][b+3]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b-1]==2&&s[a-2][b-2]==2&&s[a+1][b+1]==2&&s[a+2][b+2]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b-1]==2&&s[a-2][b-2]==2&&s[a-3][b-3]==2&&s[a+1][b+1]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b-1]==2&&s[a-2][b-2]==2&&s[a-3][b-3]==2&&s[a-4][b-4]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a+1][b]==2&&s[a+2][b]==2&&s[a+3][b]==2&&s[a+4][b]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b]==2&&s[a+1][b]==2&&s[a+2][b]==2&&s[a+3][b]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b]==2&&s[a-2][b]==2&&s[a+1][b]==2&&s[a+2][b]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b]==2&&s[a-2][b]==2&&s[a-3][b]==2&&s[a+1][b]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a-1][b]==2&&s[a-2][b]==2&&s[a-3][b]==2&&s[a-4][b]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a][b+1]==2&&s[a][b+2]==2&&s[a][b+3]==2&&s[a][b+4]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a][b-1]==2&&s[a][b+1]==2&&s[a][b+2]==2&&s[a][b+3]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a][b-1]==2&&s[a][b-2]==2&&s[a][b+1]==2&&s[a][b+2]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a][b-1]==2&&s[a][b-2]==2&&s[a][b-3]==2&&s[a][b+1]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
		if(s[a][b]==2&&s[a][b-1]==2&&s[a][b-2]==2&&s[a][b-3]==2&&s[a][b-4]==2) {
			cout<<"2Pwin"<<endl;
			system("pause");
			return 0;
		}
	}
	system("pause");

	return 0;
}

谢谢观看,好玩就来个赞和收藏吧!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值