Task Description
君平最近對暗棋非常感興趣,因此想模仿暗棋設計一個棋類小遊戲,詳細介紹如下:
此遊戲為雙人遊戲,兩位玩家分別為「奇數方」和「偶數方」。
棋盤大小是4*4。
棋子共有16顆,棋子編號從0到15。奇數方的棋子編號為1, 3, 5, ..., 15;偶數方的棋子編號為0, 2, 4, ..., 14。
棋盤上會擺放若干棋子,有棋子的位置會標示棋子編號,如果一個位置是空的,則以-1表示。
吃子規則與棋子Level表如下 :
- 只可吃相鄰棋子
- 相同Level的棋子可以互吃
- 在Level 1到7之間的棋子,Level大的棋子可吃Level小的棋子
- Level 7的棋子不能吃Level 0的棋子
- Level 0的棋子可以吃Level 7的棋子
| Level | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| 棋子編號 | 0, 1 | 2, 3 | 4, 5 | 6, 7 | 8, 9 | 10, 11 | 12, 13 | 14, 15 |
請幫君平找出盤面可吃敵方所有走步方法。
Hint
Capture.h
打上 function header 以及相關的設定。
void CaptureOppPieces(int board[4][4], int turn);
Capture.c
撰寫程式碼後對應上傳。
#include "Capture.h"void CaptureOppPieces(int board[4][4], int turn) { /* add your code */}
main.c
這個檔案無法更改也無須上傳。
123456789101112131415 #include <stdio.h>#include "Capture.h" int main() { int board[4][4], turn; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { scanf("%d", &board[i][j]); } } scanf("%d", &turn); CaptureOppPieces(board, turn); }
Input Format
前四列輸入4*4盤面棋子分布與空白位置。 第五列輸入1或0,分別表示君平 (我方) 是奇數方或偶數方。
Output Format
請印出敵方棋子被我方棋子吃掉的所有組合。
按照敵方棋子的 Level 由大到小;如果敵方棋子的 Level 相同,則按照我方棋子的 Level 由大到小印出吃子組合。
Sample Input
14 15 12 13 1 0 -1 -1-1 -1 10 811 6 7 40
Sample Output
15 is captured by 1415 is captured by 013 is captured by 127 is captured by 107 is captured by 61 is captured by 0
Sample Input
14 15 12 13 1 0 -1 -1-1 -1 10 811 6 7 41
Sample Output
14 is captured by 1514 is captured by 112 is captured by 1512 is captured by 136 is captured by 116 is captured by 74 is captured by 70 is captured by 1