你有源代码吗???可以发给我一份
我帮你看看!!!另外我这里有我自己写的一份五子棋程序!!!你看看吧!!!
程序代码:
#include<stdio.h>
#include<stdlib.h>
void main()
{
int player=0;
int winner=0;
int row=0;
int line=0;
char a[9][9]={
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '},
{' ',' ',' ',' ',' ',' ',' ',' ',' '}
};
printf("《欢迎来玩五子棋字游戏》");
for(int i=0;i<81&&winner==0;i++)
{
system("cls");
printf("\n\n");
printf(" 0 1 2 3 4 5 6 7 8 \n");
for(int b=0;b<9;b++)
{
printf(" ---+---+---+---+---+---+---+---+---\n");/*制作棋盘*/
printf("%d| %c | %c | %c | %c | %c | %c | %c | %c | %c |\n",b,a[b][0],a[b][1],a[b][2],a[b][3],a[b][4],a[b][5],a[b][6],a[b][7],a[b][8]);
}
printf(" ---+---+---+---+---+---+---+---+---\n"); /*制作棋盘*/
player=i%2+1;
do
{
printf("\nplayer %d,please enter your %c:",player,(player==1)?'X':'O');
scanf("%d,%d",&line,&row);
}while(line<0||line>9||row<0||row>9);
a[line][row]=(player==1)?'X':'O';
for(int c=0;c<9&&winner==0;c++) /* 判断机制(即每走一步都要判断是否又五子练成线) */
for(int x=0;x<5&&winner==0;x++)
if((a[c][x]==a[c][x+1]&&a[c][x]==a[c][x+2]&&a[c][x]==a[c][x+3]&&a[c][x]==a[c][x+4]&&a[c][x]==a[line][row])||
(a[x][c]==a[x+1][c]&&a[x][c]==a[x+2][c]&&a[x][c]==a[x+3][c]&&a[x][c]==a[x+4][c]&&a[x][c]==a[line][row]))
winner=player;
for(int y=0;y<5&&winner==0;y++)
for(int z=0;z<5&&winner==0;z++)
if((a[y][z]==a[y+1][z+1]&&a[y][z]==a[y+2][z+2]&&a[y][z]==a[y+3][z+3]&&a[y][z]==a[y+4][z+4]&&a[y][z]==a[line][row])||
(a[y+4][z]==a[y+3][z+1]&&a[y+4][z]==a[y+2][z+2]&&a[y+4][z]==a[y+1][z+3]&&a[y+4][z]==a[y][z+4]&&a[y+4][z]==a[line][row]))
winner=player; /* 判断机制(即每走一步都要判断是否又五子练成线) */
}
printf("\n\n");
printf(" 0 1 2 3 4 5 6 7 8 \n");
for(int b=0;b<9;b++) /*制作棋盘*/
{
printf(" ---+---+---+---+---+---+---+---+---\n");
printf("%d| %c | %c | %c | %c | %c | %c | %c | %c | %c |\n",b,a[b][0],a[b][1],a[b][2],a[b][3],a[b][4],a[b][5],a[b][6],a[b][7],a[b][8]);
}
printf(" ---+---+---+---+---+---+---+---+---\n"); /*制作棋盘*/
if(winner==0)
printf("\nhow boring,it is a draw\n");
else
printf("\nCongratulation!!!player %d,YOU ARE THE WINNER!!!\n\n",winner);
}