帮忙。。。黑白棋食棋
程序代码:
import java.util.Scanner; public class Blackwhite{ public static void main(String args[]){ int x,y; //int xy; int board[][]=new int[8][8]; int col=8; int black=1,white=2; board[3][3]=black; board[4][4]=black; board[3][4]=white; board[4][3]=white;//中心的4棋 board[0][0]=col; board[0][1]=col; board[0][2]=col; board[0][3]=col; board[0][4]=col; board[0][5]=col; board[0][6]=col; board[0][7]=col; board[1][0]=col; board[2][0]=col; board[3][0]=col; board[4][0]=col; board[5][0]=col; board[6][0]=col; board[7][0]=col; board[7][1]=col; board[7][2]=col; board[7][3]=col; board[7][4]=col; board[7][5]=col; board[7][6]=col; board[7][7]=col; board[1][7]=col; board[2][7]=col; board[3][7]=col; board[4][7]=col; board[5][7]=col; board[6][7]=col;//外栏 for ( int i = 0; i <board.length; i++ ) { System.out.print(i+" :"); for ( int j = 0; j <board.length; j++ ) { System.out.print(" "+board[i][j] ); } System.out.print("\n"); } System.out.print(" 0 1 2 3 4 5 6 7 "+"\n");//棋盘 do{ do{ System.out.print("black Enter : "); Scanner scanner = new Scanner(System.in); y = scanner.nextInt(); x = scanner.nextInt(); if(x>7||y>7||board[y][x]!=0||board[x+1][y]==0&&board[x-1][y]==0&&board[x][y-1]==0&&board[x][y+1]==0 &&board[x+1][y+1]==0&&board[x+1][y-1]==0&&board[x-1][y-1]==0&&board[x-1][y+1]==0||board[x+1][y]!=white &&board[x-1][y]!=white&&board[x][y-1]!=white&&board[x][y+1]!=white&&board[x+1][y+1]!=white&&board[x+1][y-1]!=white &&board[x-1][y-1]!=white&&board[x-1][y+1]!=white){System.out.println("error");} }while(y>6||x>6||board[y][x]!=0|| board[x+1][y]==0 &&board[x-1][y]==0 &&board[x][y-1]==0 &&board[x][y+1]==0 &&board[x+1][y+1]==0 &&board[x+1][y-1]==0 &&board[x-1][y-1]==0 &&board[x-1][y+1]==0|| board[x+1][y]!=white &&board[x-1][y]!=white &&board[x][y-1]!=white &&board[x][y+1]!=white &&board[x+1][y+1]!=white &&board[x+1][y-1]!=white &&board[x-1][y-1]!=white &&board[x-1][y+1]!=white);//要重新入棋的规则 board[y][x]=black; for ( int i = 0; i <board.length; i++ ) { System.out.print(i+" :"); for ( int j = 0; j <board.length; j++ ) { System.out.print(" "+board[i][j] ); } System.out.print("\n"); } System.out.print(" 0 1 2 3 4 5"+"\n");//黑子的输入 do{ System.out.print("white Enter : "); Scanner scanner = new Scanner(System.in); y = scanner.nextInt(); x = scanner.nextInt(); if(y>7||x>7||board[x][y]!=0||board[x+1][y]==0&&board[x-1][y]==0&&board[x][y-1]==0&&board[x][y+1]==0 &&board[x+1][y+1]==0&&board[x+1][y-1]==0&&board[x-1][y-1]==0&&board[x-1][y+1]==0||board[x+1][y]!=white &&board[x-1][y]!=white&&board[x][y-1]!=white&&board[x][y+1]!=white&&board[x+1][y+1]!=white&&board[x+1][y-1]!=white &&board[x-1][y-1]!=white&&board[x-1][y+1]!=white){System.out.println("error");} }while(x>6||y>6||board[y][x]!=0|| board[x+1][y]==0 &&board[x-1][y]==0 &&board[x][y-1]==0 &&board[x][y+1]==0 &&board[x+1][y+1]==0 &&board[x+1][y-1]==0 &&board[x-1][y-1]==0 &&board[x-1][y+1]==0|| board[x+1][y]!=black &&board[x-1][y]!=black &&board[x][y-1]!=black &&board[x][y+1]!=black &&board[x+1][y+1]!=black &&board[x+1][y-1]!=black &&board[x-1][y-1]!=black &&board[x-1][y+1]!=black);//要重新入棋的规则 board[y][x]=white; for ( int i = 0; i <board.length; i++ ) { System.out.print(i+" :"); for ( int j = 0; j <board.length; j++ ) { System.out.print(" "+board[i][j] ); } System.out.print("\n"); } System.out.print(" 0 1 2 3 4 5"+"\n");//白子的输入 }while(board[y][x]!=0);//如果有空位 } }小弟在做一个没有GUI的黑白棋
现在卡在食棋的部分
有没有人能帮帮忙吗
[ 本帖最后由 Gfung 于 2009-12-2 15:48 编辑 ]