#include <iostream>
#include<stdlib.h>
#include <fstream>
#include <sstream>
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
string a[19][19];
void color(int x)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);//(改色)
}
void logo(){
color(1);
cout<<"********** * * &&&&&&&&&&& &&&&&&&&&&&&&& ___"<<endl;
color(2);
cout<<"* * * && && |R|"<<endl;
color(3);
cout<<"* * * && && --- "<<endl;
color(4);
cout<<"* ** && && "<<endl;
color(5);
cout<<"********** 11 &&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&"<<endl;
color(6);
cout<<"* 11 && && && "<<endl;
color(7);
cout<<"* 11 && && && "<<endl;
color(8);
cout<<"* 11 &&&&&&&&&&&&&&&&&&&&& && "<<endl;
color(9);
cout<<"* 11 && "<<endl;
color(10);
cout<<"* 11 MADE IN CHNA && "<<endl;
Sleep(110);
system("CLS");
}
void printboard(){
system("CLS");
cout<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19"<<endl;
for(int k=0;k<19;k++){
if(k<9){
cout<<' ';
}
cout<<k+1<<' ';
for(int l=0;l<19;l++){
cout<<a[k][l]<<" ";
}
cout<<endl;
}
}
int main(){
for(int i=1;i<=15;i++){
for(int j=2;j<=i;j++)
cout<<endl;
logo();
}
system("color 2E");
cout<<"开始游戏!"<<endl<<"(标注:本游戏为FASTOR原创,版权所有,侵权必究)"<<endl<<endl;
Sleep(1500);
system("pause");
system("CLS");
system("color 7B");
for(int i=0;i<19;i++){
for(int j=0;j<19;j++){
a[i][j]="■";
}
}
printboard();
int i,j;
for(int ii=1;;ii++){
if(ii%2==1){
cout<<"请Player1输入坐标"<<endl ;
cin>>i>>j;
if((a[i-1][j-1]=="■")&&(i<20)&&(j<20)){
a[i-1][j-1]="О";
}else{
cout<<"输入错误" <<endl;
cout<<"请Player1重新输入坐标"<<endl ;
cin>>i>>j;
if((a[i-1][j-1]=="■")&&(i<20)&&(j<20)){
a[i-1][j-1]="О";
}else{
cout<<"输入错误"<<endl;
cout<<"请Player1最后一次输入坐标"<<endl ;
cin>>i>>j;
if((a[i-1][j-1]=="■")&&(i<20)&&(j<20)){
a[i-1][j-1]="О";
break;
}else{
cout<<"跳过白棋"<<endl;
}
}
}
}
/
else{
cout<<"请Player2输入坐标"<<endl ;
cin>>i>>j;
if((a[i-1][j-1]=="■")&&(i<20)&&(j<20)){
a[i-1][j-1]="●";
}else{
cout<<"输入错误" <<endl;
cout<<"请Player2重新输入坐标"<<endl ;
cin>>i>>j;
if((a[i-1][j-1]=="■")&&(i<20)&&(j<20)){
a[i-1][j-1]="●";
}else{
cout<<"输入错误"<<endl;
cout<<"请Player2最后一次输入坐标"<<endl ;
cin>>i>>j;
if((a[i-1][j-1]=="■")&&(i<20)&&(j<20)){
a[i-1][j-1]="●";
break;
}else{
cout<<"跳过黑棋"<<endl;
}
}
}
//a[i-1][j-1]="●";
}
printboard();
for(int r=0;r<19;r++){
for(int e=0;e<15;e++){
if((a[r][e]=="О")
&&(a[r][e+1]=="О")
&&(a[r][e+2]=="О")
&&(a[r][e+3]=="О")
&&(a[r][e+4]=="О")
){
//
cout<<"白棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 :棋谱.txt"<<endl;
} else{
}
return 0;
}else if((a[r][e]=="●")
&&(a[r][e+1]=="●")
&&(a[r][e+2]=="●")
&&(a[r][e+3]=="●")
&&(a[r][e+4]=="●")
){
cout<<"黑棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
}
}}
//横列的判断
for(int r=0;r<15;r++){
for(int e=0;e<19;e++){
if((a[r][e]=="О")
&&(a[r+1][e]=="О")
&&(a[r+2][e]=="О")
&&(a[r+3][e]=="О")
&&(a[r+4][e]=="О")
)
{
cout<<"白棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
}else if((a[r][e]=="●")
&&(a[r+1][e]=="●")
&&(a[r+2][e]=="●")
&&(a[r+3][e]=="●")
&&(a[r+4][e]=="●")
){
cout<<"黑棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
}
}}for(int r=0;r<15;r++){
for(int e=0;e<15;e++){
if((a[r][e]=="●")
&&(a[r+1][e+1]=="●")
&&(a[r+2][e+2]=="●")
&&(a[r+3][e+3]=="●")
&&(a[r+4][e+4]=="●")){
cout<<"黑棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
} else if((a[r][e]=="О")
&&(a[r+1][e+1]=="О")
&&(a[r+2][e+2]=="О")
&&(a[r+3][e+3]=="О")
&&(a[r+4][e+4]=="О")){
cout<<"白棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
}
}//for
} //for
for(int r=4;r<19;r++){
for(int e=0;e<15;e++){
if((a[r][e]=="●")
&&(a[r-1][e+1]=="●")
&&(a[r-2][e+2]=="●")
&&(a[r-3][e+3]=="●")
&&(a[r-4][e+4]=="●")){
cout<<"黑棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
} else if((a[r][e]=="О")
&&(a[r-1][e+1]=="О")
&&(a[r-2][e+2]=="О")
&&(a[r-3][e+3]=="О")
&&(a[r-4][e+4]=="О")){
cout<<"白棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
}
}//for
} //for
for(int r=0;r<15;r++){
for(int e=4;e<19;e++){
if((a[r][e]=="●")
&&(a[r+1][e-1]=="●")
&&(a[r+2][e-2]=="●")
&&(a[r+3][e-3]=="●")
&&(a[r+4][e-4]=="●")){
cout<<"黑棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
} else if((a[r][e]=="О")
&&(a[r+1][e-1]=="О")
&&(a[r+2][e-2]=="О")
&&(a[r+3][e-3]=="О")
&&(a[r+4][e-4]=="О")){
cout<<"白棋胜"<<endl;
Sleep(2000) ;
cout<<"是否打印棋谱,是1,否2"<<endl;
int pi;
cin>>pi;
if(pi==1){
ofstream copy;
copy.open("棋谱.txt");
copy<<" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19";
copy<<endl;
for(int k=0;k<19;k++){
if(k<9){
copy<<' ';
}
copy<<k+1<<' ';
for(int l=0;l<19;l++){
copy<<a[k][l]<<" ";
}
copy<<endl;
}
copy.close();
cout<<"已保存为 棋谱.txt"<<endl;
} else{
}
return 0;
}
}
}
}
}
五子棋程序
于 2023-08-03 16:08:38 首次发布