時限:1000ms 記憶體限制:10000k 總時限:3000ms
描述:
經過前3題的熱身相信大家已經對黑白棋有了一定的認識,下面我們來編寫稍微複雜一點的模組。黑白棋並不像5子棋或者圍棋一樣可以在任意空白處下子,那麼檢測某個位置是否可以下子(如對規則還不是很了解,請參照前3題的規則介紹),也是我們黑白棋ai演算法會經常呼叫的模組。下面需要同學們編寫這一檢測模組。
輸入:
首先讀入的是當前棋盤的狀態,共8行,每行8個數字,1代表白棋,2代表黑棋,0代表為空格(未下子)。第9行有3個數字r c n,分別代表給定點的行、列還有所要下子的顏色。
輸出:
輸出對於這個位置是否可以落子,可以輸出yes,不可以則輸出no.
輸入樣例:
0 0 0 0 0 0 0 00 0 0 0 0 0 1 0
0 0 0 2 0 2 0 0
0 0 1 2 2 2 0 0
0 0 0 2 1 0 0 0
0 0 0 2 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
2 4 1
輸出樣例:
yes#include
using namespace std;
int shang();
int xia();
int zuo();
int you();
int zuoshang();
int youshang();
int zuoxia();
int youxia();
int qipan[8][8];
int row,col,color;
int main()
} cin>>row;
cin>>col;
cin>>color;
if(shang()||xia()||zuo()||you()||zuoshang()||youshang()||zuoxia()||youxia())
//判斷向上方向是否可連線
int shang()
else
}if(counter>1&&i>=0&&qipan[i][col]==color)
return(flag);
}//判斷向下
int xia()
else
}if(counter>1&&i<8&&qipan[i][col]==color)
return(flag);
}//判斷向左
int zuo()
else
}if(counter>1&&i>=0&&qipan[row][i]==color)
return(flag);
}//判斷向右
int you()
else
}if(counter>1&&i<8&&qipan[row][i]==color)
return(flag);
}//判斷左上
int zuoshang()
else
}} if(flag1==1)
}if(counter>1&&i>=0&&j>=0&&qipan[i][j]==color)
return(flag);
}//判斷右上
int youshang()
else
}} if(flag1==1)
} if(counter>1&&i>=0&&j<8&&qipan[i][j]==color)
return(flag);
}//判斷左下
int zuoxia()
else
}} if(flag1==1)
}if(counter>1&&i<8&&j>=0&&qipan[i][j]==color)
return(flag);
}//判斷右下
int youxia()
else
}} if(flag1==1)
}if(counter>1&&i<8&&j<8&&qipan[i][j]==color)
return(flag);
}
黑白棋 C 版本
using system using system.drawing using system.threading using system.windows.forms private void show can position 統計可以落子的位置數 private intshow can num ...
黑白棋遊戲
黑白棋遊戲 time limit 10000ms memory limit 65536k total submit 9 accepted 5 case time limit 1000ms description 問題描述 黑白棋遊戲的棋盤由4 4方格陣列構成。棋盤的每一方格中放有1枚棋子,共有8枚白...
黑白棋遊戲
用c 封裝了一下,只完成了乙個雛形,有很多功能沒有新增上,但 的行數已經縮短了很多了。include include include includeusing namespace std class chess int counter 計數器,計算棋子個數 const friend void dra...