模拟题,我的做法是先让黑将分别上下左右移动,对每一种情况  先判断是否能被马将死(列举8种情况),然后判断是否能被 将 车 炮 将死(以黑将为中心十字展开,判断是否有 将 车 炮)

注意:

1.开局两将正对红方必输;

2.吃子情况;

3.输入问题(因为输入错了好多次)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

int main()
{
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
int judgewin(int qipan[15][15], int x, int y);
int qipan[15][15];
char s[5];
int n,x,y;
while(scanf("%d %d %d", &n, &x, &y) == 3 && n && x && y){
memset(qipan,0,sizeof(qipan));//制盘
int x1, y1;
while(n--){
scanf("%s%d%d", s, &x1, &y1);
qipan[x1][y1] = s[0];
}//放子

if(judgewin(qipan,x,y)) printf("YES\n");
else printf("NO\n");
}
}

int judgewin(int qipan[15][15], int x, int y)
{
int judge(int qipan[15][15], int x, int y);
char ch;

int i;
for(i = x; i <= 10; i++)
if(qipan[i][y] != 0) break;
if(i <=10 && qipan[i][y] == 'G') return 0;

/*上*/
if(x-1 >= 1){
ch = qipan[x-1][y];
qipan[x-1][y] = 0;
if(judge(qipan,x-1,y)) return 0;
}
qipan[x-1][y] = ch;
/*下*/
if(x+1 <= 3){
ch = qipan[x+1][y];
qipan[x+1][y] = 0;
if(judge(qipan,x+1,y)) return 0;
}
qipan[x+1][y] = ch;
/*左*/
if(y-1 >= 4){
ch = qipan[x][y-1];
qipan[x][y-1] = 0;
if(judge(qipan,x,y-1)) return 0;
}
qipan[x][y-1] = ch;
/*右*/
if(y+1 <= 6){
ch = qipan[x][y+1];
qipan[x][y+1] = 0;
if(judge(qipan,x,y+1)) return 0;
}
qipan[x][y+1] = ch;

return 1;
}


int judge(int qipan[15][15], int x, int y)
{
/*马*/
if(qipan[x+1][y-2] == 'H' && qipan[x+1][y-1] == 0) return 0;
if(qipan[x+2][y-1] == 'H' && qipan[x+1][y-1] == 0) return 0;
if(qipan[x+1][y+2] == 'H' && qipan[x+1][y+1] == 0) return 0;
if(qipan[x+2][y+1] == 'H' && qipan[x+1][y+1] == 0) return 0;
if(x-1>=1 && qipan[x-1][y+2] == 'H' && qipan[x-1][y+1] == 0) return 0;
if(x-2>=1 && qipan[x-2][y+1] == 'H' && qipan[x-1][y+1] == 0) return 0;
if(x-2>=1 && qipan[x-2][y-1] == 'H' && qipan[x-1][y-1] == 0) return 0;
if(x-1>=1 && qipan[x-1][y-2] == 'H' && qipan[x-1][y-1] == 0) return 0;
/*炮 车 将*/
int i, num = 0;
for(i = x; i >= 1; i--){
if(num == 1 && qipan[i][y] != 0){
num++;
if(qipan[i][y] == 'C') return 0;
}
if(qipan[i][y] != 0 && num == 0){
num++;
if(qipan[i][y] =='R') return 0;
}
}
num = 0;
for(i = x; i <= 10; i++){
if(num == 1 && qipan[i][y] != 0){
num++;
if(qipan[i][y] == 'C') return 0;
}
if(qipan[i][y] != 0 && num == 0){
num++;
if(qipan[i][y] == 'G' || qipan[i][y] =='R') return 0;
}
}
num = 0;
for(i = y; i >= 1; i--){
if(num == 1 && qipan[x][i] != 0){
num++;
if(qipan[x][i] == 'C') return 0;
}
if(qipan[x][i] != 0 && num == 0){
num++;
if(qipan[x][i] =='R') return 0;
}
}
num = 0;
for(i = y; i <= 9; i++){
if(num == 1 && qipan[x][i] != 0){
num++;
if(qipan[x][i] == 'C') return 0;
}
if(qipan[x][i] != 0 && num == 0){
num++;
if(qipan[x][i] =='R') return 0;
}
}

return 1;
}