#include<ctypeh>
#include<stdioh>
#include<dosh>
#include<conioh>
#include<ctypeh>
#include<biosh>
#define SHURU 1
#define FANGXIANG 2
#define WUXIAO 0
#define TUICHU 3
//
static int ii=0,jj=0,wanjia=1;
//
void hqp(int a[][20],int y);
int anjian(char an);
int panduan(int a[][20]);
void pingmu(void);
void guangbiaoyd(char an);
void jh(int a[][20]);
//
void main()
{
int a[20][20]={0},tuichu=0,ying;
char an;
hqp(a,0);
pingmu();
while(1)
{
ying=panduan(a);
if(ying!=0)
hqp(a,ying);
an=getch();
switch(anjian(an))
{
case TUICHU:clrscr();
tuichu=1;
break;
case FANGXIANG:guangbiaoyd(an);
break;
case SHURU: switch(ying)
{
case 1:hqp(a,1);tuichu=1;break;
case 2:hqp(a,2);tuichu=1;break;
case 0:jh(a);break;
}
break;
case WUXIAO:break;
}
hqp(a,0);
pingmu();
if(tuichu==1)
break;
}
}
//
void hqp(int a[][20],int y)
{
int i,j;
clrscr();
if(y!=0)
{
textcolor(RED);
printf("WAN JIA %d SHENG LI! ! ! ! ! \n",y);
}
for(i=0;i<20;i++)
{
for(j=0;j<20;j++)
{
switch(a[i][j])
{
case 1: textcolor(YELLOW);
putch('X');
break;
case 2: textcolor(BLUE);
putch('0');
break;
case 0: textcolor(GREEN);
if(j==0)
{
if(i==0)
{
putch(0xda);
break;
}
if(i==19)
{
putch(0xc0);
break;
}
putch(0xc3);
break;
}
if(j==19)
{
if(i==0)
{
putch(0xbf);
break;
}
if(i==19)
{
putch(0xd9);
break;
}
putch(0xb4);
break;
}
if(i==0&&j!=0&&j!=19)
{
putch(0xc2);
break;
}
if(i==19&&j!=0&&j!=19)
{
putch(0xc1);
break;
}
putch(0xc5);
break;
}
}
printf("\n");
}
}
//
int anjian(char an)
{
if(an==32||an==13)
return(SHURU);
else
if(an=='a'||an=='w'||an=='s'||an=='d'||
an=='j'||an=='i'||an=='k'||an=='l')
return(FANGXIANG);
else
if(an==27)
return(TUICHU);
else
return(WUXIAO);
}
//
int panduan(int a[][20])
{
int i,j;
for(i=0;i<20;i++)
{
for(j=0;j<15;j++)
{
if(a[i][j]==1&&a[i][j+1]==1&&a[i][j+2]==1&&a[i][j+3]==1&&a[i][j+4]==1)
return(1);
else
if(a[i][j]==2&&a[i][j+1]==2&&a[i][j+2]==2&&a[i][j+3]==2&&a[i][j+4]==2)
return(2);
}
}
for(i=0;i<15;i++)
{
for(j=0;j<20;j++)
{
if(a[i][j]==1&&a[i+1][j]==1&&a[i+2][j]==1&&a[i+3][j]==1&&a[i+4][j]==1)
return(1);
else
if(a[i][j]==2&&a[i+1][j]==2&&a[i+2][j]==2&&a[i+3][j]==2&&a[i+4][j]==2)
return(2);
}
}
for(i=0;i<15;i++)
{
for(j=0;j<15;j++)
{
if(a[i][j]==1&&a[i+1][j+1]==1&&a[i+2][j+2]==1&&a[i+3][j+3]==1&&a[i+4][j+4]==1)
return(1);
else
if(a[i][j]==2&&a[i+1][j+1]==2&&a[i+2][j+2]==2&&a[i+3][j+3]==2&&a[i+4][j+4]==2)
return(2);
}
}
for(i=4;i<20;i++)
{
for(j=4;j<20;j++)
{
if(a[i][j]==1&&a[i-1][j-1]==1&&a[i-2][j-2]==1&&a[i-3][j-3]==1&&a[i-4][j-4]==1)
return(1);
else
if(a[i][j]==2&&a[i-1][j-1]==2&&a[i-2][j-2]==2&&a[i-3][j-3]==2&&a[i-4][j-4]==2)
return(2);
}
}
return(0);
}
//
void pingmu(void)
{
int i,j;
char Msg[]=
{
"Wan Jia1 an jian:",
" shang: w",
" xia: s",
" zuo: a",
" you: d",
" fang zi: space",
"",
"Wan Jia2 an jian:",
" shang: i",
" xia: k",
" zuo: j",
" you: l",
" fang zi: ENTER",
"tui chu:",
" ESC\n",
NULL,
};
i=0;
textcolor(RED);
while(Msg[i]!=NULL)
{
gotoxy(25,3+i);
cputs(Msg[i]);
i++;
}
gotoxy(25,20);
printf("\nqing wan jia %d chu ru:",wanjia);
gotoxy(jj+1,ii+1);
}
//
void guangbiaoyd(char an)
{
if(wanjia==1)
{
switch(an)
{
case 'a': jj--;break;
case 'd': jj++;break;
case 'w': ii--;break;
case 's': ii++;break;
}
}
else
{
switch(an)
{
case 'j': jj--;break;
case 'l': jj++;break;
case 'i': ii--;break;
case 'k': ii++;break;
}
}
if(ii<0)
ii++;
if(ii>19)
ii--;
if(jj<0)
jj++;
if(jj>19)
jj--;
gotoxy(ii+1,jj+1);
}
//
void jh(int a[][20])
{
int k=0;
if(wanjia==1&&a[ii][jj]==0&&k==0)
{
a[ii][jj]=1;
wanjia=2;
k=1;
}
else
{
if(a[ii][jj]==0&&k==0)
{
a[ii][jj]=2;
wanjia=1;
}
}
}
//
我手头上有一个不能人机对战的用java编写的界面,可以判定输赢的。
//界面代码
import javaawt;
import javaxswing;
import javaawteventWindowAdapter;
import javaawteventWindowEvent;
import javaawtevent;
import javaxswing;
class drawChessBoard extends Canvas
{
//Image image;
Image image_black,image_white,image_point;
ImageIcon imageIcon_black = new ImageIcon("E:/workspace/五子棋/res/Image/blackjpg");
ImageIcon imageIcon_white = new ImageIcon("E:/workspace/五子棋/res/Image/whitejpg");
ImageIcon imageIcon_point = new ImageIcon("E:/workspace/五子棋/res/pointjpg");
isWin win = new isWin();
int locate =0;
int count =0;
static int drawCount = 0;
static String str;
public void paint(Graphics g)
{
int row = 0,column = 0;
chessboard chessBoard = new chessboard();
drawChessBoard draw = new drawChessBoard();
image_black = imageIcon_blackgetImage();
image_white = imageIcon_whitegetImage();
image_point = imageIcon_pointgetImage();
int temp_x = 0,temp_y = 0;
//画棋盘
for(row = 0;row < 16;row ++)
{
gdrawLine(0,40 + row 40, 640, 40 + row 40);
gdrawLine(40 + row 40, 0, 40 + row 40, 640);
// gdrawImage(image_point,317,317,imageIcon_pointgetIconWidth(),imageIcon_pointgetIconHeight(),imageIcon_pointgetImageObserver());
// gdrawImage(image_point,477,157,imageIcon_pointgetIconWidth(),imageIcon_pointgetIconHeight(),imageIcon_pointgetImageObserver());
// gdrawImage(image_point,157,157,imageIcon_pointgetIconWidth(),imageIcon_pointgetIconHeight(),imageIcon_pointgetImageObserver());
// gdrawImage(image_point,157,477,imageIcon_pointgetIconWidth(),imageIcon_pointgetIconHeight(),imageIcon_pointgetImageObserver());
// gdrawImage(image_point,477,477,imageIcon_pointgetIconWidth(),imageIcon_pointgetIconHeight(),imageIcon_pointgetImageObserver());
for(column = 0;column < 16;column ++)
{
if( chessboardchess_state[row][column] == 1)
{
gdrawImage(image_black,20 + row 40,20 + column 40,imageIcon_blackgetIconWidth(),imageIcon_blackgetIconHeight(),imageIcon_blackgetImageObserver());
}
else if(chessboardchess_state[row][column] == 2)
{
gdrawImage(image_white,20 + row 40,20 + column 40,imageIcon_whitegetIconWidth(),imageIcon_whitegetIconHeight(),imageIcon_whitegetImageObserver());
}
}
}
//画棋子
if(count != 0 && chessboardisStart)
{
if(chessboardcoordinate_x / 40 >= 0 && chessboardcoordinate_x / 40 < 16 && chessboardcoordinate_y / 40 >= 0 && chessboardcoordinate_y / 40 < 16)
{
if(chessboardisBlack && chessboardchess_state[chessboardcoordinate_x / 40][chessboardcoordinate_y / 40] == 0 )
{
gdrawImage(image_black,20 + chessBoardcoordinate_x,20 + chessBoardcoordinate_y,imageIcon_blackgetIconWidth(),imageIcon_blackgetIconHeight(),imageIcon_blackgetImageObserver());
chessboardisBlack = false;
chessboardisWhite = true;
chessboardchess_state[ chessboardcoordinate_x / 40 ][ chessboardcoordinate_y / 40 ] = 1;
// chessboardchess_state[chessboardcoordinate_x / 40 - 1][chessboardcoordinate_y / 40 - 1] = 2;
//判断黑子是否赢
str = winwinJudge( chessboardcoordinate_x / 40,chessboardcoordinate_y / 40 );
}
if(chessboardisWhite && chessboardchess_state[chessboardcoordinate_x / 40][chessboardcoordinate_y / 40] == 0 )
{
gdrawImage(image_white,20 + chessBoardcoordinate_x,20 + chessBoardcoordinate_y,imageIcon_whitegetIconWidth(),imageIcon_whitegetIconHeight(),imageIcon_whitegetImageObserver());
// gdrawImage(image_white,temp_x - 40,temp_y - 40,imageIcon_whitegetIconWidth(),imageIcon_whitegetIconHeight(),imageIcon_whitegetImageObserver());
chessboardisWhite = false;
chessboardisBlack = true;
chessboardchess_state[chessboardcoordinate_x / 40][chessboardcoordinate_y / 40] = 2;
//判断白子是否赢
str = winwinJudge(chessboardcoordinate_x / 40,chessboardcoordinate_y / 40 );
}
}
}
count ++;
}
public void update(Graphics g)
{
chessboard chessBoard = new chessboard();
//覆盖问题
if((chessboardisChange || chessboardchess_state[chessboardcoordinate_x / 40][chessboardcoordinate_y / 40] == 0) && chessboardisStart )
{
superupdate(g);
chessboardisChange = false;//重写update方法
}
}
}
public class chessboard extends Frame implements MouseListener,ActionListener,MouseMotionListener
{
Button button = new Button("开始游戏");
Button button_exit = new Button("退出游戏");
static boolean isChange = false;
static boolean isStart = false;
drawChessBoard draw = new drawChessBoard();
int i ,j;
Panel panel = new Panel(),p;
static boolean isBlack = true,isWhite = false;
static boolean isPlayer = true,isComputer = false;
static int coordinate_x = 0,coordinate_y = 0;
static int chess_state[][] = new int[17][17];
JRadioButton black_radio,white_radio;
Label result_label;
chessboard(String name)
{
for(i = 0;i < 17;i ++)
{
for(j = 0;j < 17;j ++)
{
chess_state[i][j] = 0;
}
}
Color color = new Color(210,210,210);
paneladd(button);
panelsetLayout(null);
result_label = new Label();//创建标签
black_radio = new JRadioButton("黑棋",false);
white_radio = new JRadioButton("白棋",false);
black_radiosetBounds(680,80,40,20);
black_radiosetBounds(720,80,40,20);
result_labelsetBounds(680,220,80,40);
buttonsetBounds(680,100,80,40);
button_exitsetBounds(680,160,80,40);
thisadd(button);
thisadd(button_exit);
thisadd(result_label);
thisadd(black_radio);
thisadd(white_radio);
p = new Panel();
psetLayout(null);
psetBackground(color);
// thisadd(drawchess);
thisadd(draw);
//
thissetBounds(300, 20, 800, 700);
drawaddMouseListener(this);//监听draw
drawaddMouseMotionListener(this);
buttonaddActionListener(this);
button_exitaddActionListener(this);
thisaddWindowListener(new MyWindowListener());
thissetVisible(true);
}
chessboard()
{
}
public void actionPerformed(ActionEvent e)
{
if((Button)egetSource() == button_exit)
{
Systemexit(0);
}
else if ((Button)egetSource() == button)
{
isStart = true;
result_labelsetText("游戏进行中");
for(i = 0;i < 17;i ++)
{
for(j = 0;j < 17;j ++)
{
chessboardchess_state[i][j] = 0;
}
}
drawrepaint();
}
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
chessboard chess = new chessboard();
if(chesscoordinate_x <= 640 && chesscoordinate_y <= 640 && chesscoordinate_x >= 0 && chesscoordinate_y >= 0 )
{
drawrepaint();
}
}
public void mouseReleased(MouseEvent e)
{
if(isStart == false)
{
result_labelsetText(drawChessBoardstr);
}
//电脑落子调用mouseReleased
/
if(chessboardisComputer)
{
drawrepaint();
}
/
}
public void mouseExited(MouseEvent e)
{
}
public void mouseDragged(MouseEvent e)
{
// Systemexit(0);
}
public void mouseMoved(MouseEvent e){
Integer integ1,integ2 ;
chessboardisChange = true;
coordinate_x = egetX();
coordinate_y = egetY();
// integ1 = new Integer(coordinate_x / 40);
// integ2 = new Integer(coordinate_y / 40);
// result_labelsetText(integ1toString()+" "+integ2toString());
if(coordinate_x <= 20)
{
coordinate_x = (coordinate_x / 40 + 1) 40;
}
if(coordinate_y <= 20)
{
coordinate_y = (coordinate_y / 40 + 1) 40;
}
if( coordinate_x % 40 <=20 )
{
coordinate_x = (coordinate_x / 40 -1) 40;
}
else
{
coordinate_x = (coordinate_x / 40 ) 40;
}
if( coordinate_y % 40 <=20 )
{
coordinate_y = (coordinate_y / 40 - 1 ) 40;
}
else
{
coordinate_y = (coordinate_y / 40 ) 40;
}
}
public static void main(String args[])
{
chessboard cb = new chessboard("五子棋");
}
}
class MyWindowListener extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
Systemexit(0);
}
}
//判断输赢
public class isWin {
//static int count = 0;
public String winJudge(int row,int col)
{
chessboard chessBoard = new chessboard();
int index,count = 1;
int n = 0 ,flag = 1;
boolean isOneside = true, isAnotherside = true;
if(chessboardchess_state[row][col] != 0)
{
//水平方向判断
for(index = 0;index < 5;index ++)
{
//向落子点右边扫描
while(isOneside)
{
if(n == 0) count = 1;
if(row + count <= 16 && chessboardchess_state[ row + count][ col ] == chessboardchess_state[ row ][ col ] )
{
flag ++;
n ++;
count ++;
}
else
{
isOneside = false;
n = 0;
break;
}
}
//向落子点左边扫面
while(!isOneside)
{
if(n == 0) count = 1;
if(row - count >= 0 && chessboardchess_state[ row - count ][ col ] == chessboardchess_state[ row ][ col ] && !isOneside && row > 1)
{
flag ++;
count ++;
n ++;
}
else
{
isOneside = true;
n = 0;
break;
}
}
//如果左边没有落子或者落了颜色不同的子
if(flag >= 5)
{
chessboardisStart = false;
if(chessboardchess_state[row][col] == 1)
{
return "黑子赢了";
}
else
{
return "白子赢了";
}
}
if(flag < 5)
flag = 1;
}
//竖直方向判断
for(index = 0;index < 5;index ++)
{
while(isOneside)
{
if( n == 0 )
{
count = 1;
}
if(col + count <= 16 && chessboardchess_state[ row ][ col + count ] == chessboardchess_state[ row ][ col ] )
{
flag ++;
n ++;
count ++;
}
else
{
isOneside = false;
n = 0;
break;
}
}
//向落子点左边扫面
while(!isOneside)
{
if(n == 0) count = 1;
if(col - count >= 0 && chessboardchess_state[ row ][ col - count ] == chessboardchess_state[ row ][ col ] && !isOneside )
{
flag ++;
n ++;
count ++;
}
else
{
isOneside = true;
n = 0;
break;
}
}
//如果左边没有落子或者落了颜色不同的子
if(flag >= 5)
{
chessboardisStart = false;
if(chessboardchess_state[row][col] == 1)
{
return "黑子赢了";
}
else if(chessboardchess_state[row][col] == 2)
{
return "白子赢了";
}
}
if(flag < 5)
flag = 1;
}
//斜向上方向判断
for(index = 0;index < 5;index ++)
{
//向落子点右边扫描
while(isOneside)
{
if(n == 0) count = 1;
if( chessboardchess_state[ row + count][ col + count ] == chessboardchess_state[ row ][ col ] )
{
flag ++;
n ++;
count ++;
}
else
{
isOneside = false;
n = 0;
break;
}
}
//向落子点左边扫面
while(!isOneside)
{
if(n == 0) count = 1;
if(row - count >= 0 && col - count >= 0 && chessboardchess_state[ row - count][ col - count ] == chessboardchess_state[ row ][ col ] && !isOneside)
{
flag ++;
count ++;
n ++;
}
else
{
isOneside = true;
n = 0;
break;
}
}
//如果左边没有落子或者落了颜色不同的子
if(flag >= 5)
{
chessboardisStart = false;
if(chessboardchess_state[row][col] == 1)
{
return "黑子赢了";
}
else
{
return "白子赢了";
}
}
if(flag < 5)
flag = 1;
}
//斜向下方向判断
for(index = 0;index < 5;index ++)
{
//向落子点右边扫描
while(isOneside)
{
if(n == 0) count = 1;
if(row - count >= 0 && col + count <= 16 && chessboardchess_state[ row - count][ col + count] == chessboardchess_state[ row ][ col ] )
{
flag ++;
n ++;
count ++;
}
else
{
isOneside = false;
n = 0;
break;
}
}
//向落子点左边扫面
while(!isOneside)
{
if(n == 0) count = 1;
if(row + count <= 16 && col - count >= 0 && chessboardchess_state[ row + count][ col - count ] == chessboardchess_state[ row ][ col ] && !isOneside)
{
flag ++;
count ++;
n ++;
}
else
{
isOneside = true;
n = 0;
break;
}
}
//如果左边没有落子或者落了颜色不同的子
if(flag >= 5)
{
chessboardisStart = false;
if(chessboardchess_state[row][col] == 1)
{
return "黑子赢了";
}
else
{
return "白子赢了";
}
}
if(flag < 5)
flag = 1;
}
}//if
return "0";
}
public static void main(String args[])
{
isWin winjudge = new isWin();
//winjudgewinJudge(row, col);
}
}
BOOL check(CPoint point,int type,int w,int h)//point 是用来标志当前棋子的位置,type 是黑白方 w h棋盘的大小
{
int num=-1;
int i=0,j=0,sta=0;
for(i=pointx,j=pointx;i>=0&&j<w;)
{
sta=0;
if(i>=0&&n_map[pointy][i]==type)
{
++sta;
++num;
--i;
}
if(j<w&&n_map[pointy][j]==type)
{
++sta;
++num;
++j;
}
if(sta==0) break;
}
if(num>=5) return true;//横
num=-1;
for(i=pointy,j=pointy;i>=0&&j<h;)
{
sta=0;
if(i>=0&&n_map[i][pointx]==type)
{
++sta;
++num;
--i;
}
if(j<h&&n_map[j][pointx]==type)
{
++sta;
++num;
++j;
}
if(sta==0) break;
}
if(num>=5) return true;//竖
num=-1;
for(i=0,j=0;i<5&&j<5;)
{
sta=0;
if((pointy-i)>=0&&(pointx+i)<w&&n_map[pointy-i][pointx+i]==type)//上
{
++sta;
++num;
++i;
}
if((pointy+j)<h&&(pointx-j)>=0&&n_map[pointy+j][pointx-j]==type)//下
{
++sta;
++num;
++j;
}
if(sta==0) break;
}
if(num>=5) return true;//撇
num=-1;
for(i=0,j=0;i<5&&j<5;)
{
sta=0;
if((pointy-i)>=0&&(pointx-i)>=0&&n_map[pointy-i][pointx-i]==type)//上
{
++sta;
++num;
++i;
}
if((pointy+j)<h&&(pointx+j)<w&&n_map[pointy+j][pointx+j]==type)//下
{
++sta;
++num;
++j;
}
if(sta==0) break;
}
if(num>=5) return true;//
return false;
}
//n_map[][]为棋盘 如果值为1 表示为黑方,-1表示白方
如果想源码的话,702477275@qqcom这是我的邮箱。
说实话,你写的C++比较不规范,下面是我改的,你可以看看。。。
#include<iostream>
#include<stdlibh>
using namespace std;
const int N=15;
const int M=15; //c++中有常变量代替c中的宏定义,宏定义不错语法检查
//int main(); main函数是入口函数,不必提前声明,删掉
//貌似你后面调用了main函数,这不规范,看看我改的吧
void init(char flag[][M])
{
for(int i=1;i<N;i++) //数组都是从0开始的,最好改成for(int i=0;i<N;i++)
{for(int j=1;j<M;j++) //你这样写有点浪费内存空间,虽说语法没错。。
{ flag[i][j]='_';
cout<<flag[i][j];
cout<<"|";
}
cout<<endl;
}
}
void draw(char flag[][M])
{for(int i=1;i<N;i++) //这两处与上面一样
{for(int j=1;j<M;j++) //
{cout<<flag[i][j];
cout<<'|';}
cout<<endl;
}
}
void ciin(char flag[][M],char t,char v)
{
cout<<"请"<<t<<"走,";
int i,j;
cout<<"请输入两个小于"<<N<<"的数字:"<<endl;
cin>>i;
cin>>j;
while(i>=N||i<1||j>=M||j<1||flag[i][j]=='#'||flag[i][j]=='0')
{if(i>=N||i<1||j>=M||j<1)
{cout<<"输入错误,请重新输入";
cout<<"请输入两个小于"<<N<<"的数字:"<<endl;//还要提示不小于1
cin>>i;
cin>>j;
}
else
{cout<<"此处有棋子,请重新输入";
cout<<"请输入两个小于"<<N<<"的数字:"<<endl;
cin>>i;
cin>>j;
}
}
flag[i][j]=v;
draw(flag); //这句可以删去了,没有意义
system("clear");
draw(flag);
cout<<endl;
}
int test(char flag[][M],char t) //若是想再来一局返回1,否则返回0
{int i,j;
for(i=1;i<N;i++)
{for(j=1;j<M;j++)
if((flag[i][j]=='#'&&flag[i][j+1]=='#'&&flag[i][j+2]=='#'&&flag[i][j+3]=='#'&&flag[i][j+4]=='#')||
(flag[i][j]=='0'&&flag[i][j+1]=='0'&&flag[i][j+2]=='0'&&flag[i][j+3]=='0'&&flag[i][j+4]=='0')||
(flag[i][j]=='#'&&flag[i+1][j]=='#'&&flag[i+2][j]=='#'&&flag[i+3][j]=='#'&&flag[i+4][j]=='#')||
(flag[i][j]=='0'&&flag[i+1][j]=='0'&&flag[i+2][j]=='0'&&flag[i+3][j]=='0'&&flag[i+4][j]=='0')||
(flag[i][j]=='#'&&flag[i+1][j+1]=='#'&&flag[i+2][j+2]=='#'&&flag[i+3][j+3]=='#'&&flag[i+4][j+4]=='#')||
(flag[i][j]=='0'&&flag[i+1][j+1]=='0'&&flag[i+2][j+2]=='0'&&flag[i+3][j+3]=='0'&&flag[i+4][j+4]=='0')||
(flag[i][j]=='#'&&flag[i+1][j-1]=='#'&&flag[i+2][j-2]=='#'&&flag[i+3][j-3]=='#'&&flag[i+4][j-4]=='#')||
(flag[i][j]=='0'&&flag[i+1][j-1]=='0'&&flag[i+2][j-2]=='0'&&flag[i+3][j-3]=='0'&&flag[i+4][j-4]=='0'))
{cout<<t<<"胜,你服不?还想被虐不?Y/N:"<<endl;
char c;
cin>>c;
if(c=='y'||c=='Y')
//main(); //调用main函数,我没试过。。。你可以改变一下main函
return 1; //中的语句来实现,还是删掉吧
else
return 0;}
}
}
int main1() //将main函数改成main1,让main1封装所有功能。
{
char flag[N][M];
init(flag);
cout<<endl;
for(int i=0;i<(N-1)(M-1);i++)
{
ciin(flag,'A','#');
if(test(flag,'A')==1)
{return 1;} //这是还想再来一局的意思
ciin(flag,'B','0');
if(test(flag,'B')==1)
{return 1;}
}
return 0;
}
void main()
{
while(1)
{
if(main1()==0)
break; //如果不想继续,则退出循环结束程序
else
continue; //如果想继续,则重新循环。
}
}
最后再说几句,C++的经典之处在与封装,他更倾向于面向对象程序设计,而你的思维还局限在C语言中,没有领悟到C++的经典之处,有待揣摩,其实,你可以做成一个class类,将所有的东西封装在里面,然后创建一个类对象就好了。这样做才是真正的C++
鉴定完毕
以上就是关于用c语言编写一个可以用鼠标控制的五子棋程序全部的内容,包括:用c语言编写一个可以用鼠标控制的五子棋程序、如何用C语言做一个五子棋程序要有源代码。、用C语言编五子棋程序,,只要写出棋盘还有垂直水平一个对角线方向的成功判断即可等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)