五子棋的棋盘为10x10,使用0表示空子,1表示白子,-1表示黑子,求给出一个程序判断黑子获胜还是白子获胜.还有,我不会下围棋,谁能给个围棋的输赢的规则.>>>>>谢谢拉!!!!!!!!

解决方案 »

  1.   

    int p[][]=new int[10][10];
    ....
    //落子后判断
    //int pointX,int pointY 落子坐标
    public boolean hasVictory(int pointX,int pointY)
    {
    int i_temp=p[pointX][pointY]; int count=1;
    int x=pointX;
    int y=pointY;//横向判断
    while(x>0 && i_temp=p[--x][y]) count++;
    while(x<9 && i_temp=p[++x][y]) count++;
    if(count>=5) return true;//纵向判断
    count=1;
    x=pointX;
    y=pointY;
    while(y>0 && i_temp=p[x][--y]) count++;
    while(y<9 && i_temp=p[x][++y]) count++;
    if(count>=5) return true;

    //斜向判断1
    count=1;
    x=pointX;
    y=pointY;
    while(y>0 && x>0 && i_temp=p[--x][--y]) count++;
    while(y<9 && x<9 && i_temp=p[++x][++y]) count++;
    if(count>=5) return true;//斜向判断2
    count=1;
    x=pointX;
    y=pointY;
    while(y>0 && x<9 && i_temp=p[++x][--y]) count++;
    while(y<9 && x>0 && i_temp=p[--x][++y]) count++;
    if(count>=5) return true;

    return false;
    }