分页:
上一页 1 2 3 4 5 6 7 8 [9] 10 下一页
struct position { int row; int col;
}; /*棋子位置*/
struct killed { struct position data[max_num]; int num;
} *p; /*存储可以吃掉的棋子位置*/
struct stack { struct position node[max_num]; int top;
}; /*栈*/
int w[length][length]; /*棋盘中双方的棋子分布*/
int visited[length][length]; /*给已搜索到的棋子位置作标记,初值为0,搜索到后为1*/
struct killed *kill(int w[length][length],int r,int c,int tag)
{ struct killed *p;
struct position *s;
struct stack S;
for (i=0;i<length;i++)
for (j=0;j<length;j++)
(1) ;
S.top=-1; p->num=-1;
if (w[r-1][c]==tag*(-1)) s->row=r-1; s->col=c;
else if (w[r+1][c]==tag*(-1)) s->row=r+1; s->col=c;
else if (w[r][c-1]==tag*(-1)) s->row=r; s->col=c-1;
else if (w[r][c+1]==tag*(-1)) s->row=r; s->col=c+1;
else p->len=0; return p;
push(S,s); visited[s->row][s->col]=1;
flag=search(s,tag);
while ( (2))
{ push(S,s); visited[s->row][s->col]=1;
(3);
}
while (S->top>=0)
{ pop(S);
(4);
flag=search(s,tag);
while (flag)
{ push(S,s);
visit(s);
flag=search(s);
}
}
}
void push( struct stack *S, struct position *s)
{ S->top++;
S->node[S->top].row=s->row;
S->node[S->top].col=s->col;
p->num++;
p->data[p->num].row=s->row;
分页:
上一页 1 2 3 4 5 6 7 8 [9] 10 下一页