考试网 >> IT认证 >> 水平 >> 软件指导 >> 程序员数据结构笔记(三)

程序员数据结构笔记(三)

发布时间:2006-06-28 04:46     点击:
分页:上一页  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  下一页
版权申明:未经书面授权请勿转载本站信息!!作品版权归所属媒体与作者所有!!
发表评论: 匿名发表 用户名: 查看评论
您将承担一切因您的行为、言论而直接或间接导致的民事或刑事法律责任
留言板管理人员有权保留或删除其管辖留言中的任意内容
本站提醒:不要进行人身攻击。谢谢配合。
在本站搜索相关信息
2003-2005 Ksw123.com All Rights Reserved. - TOP
Copyright © 2006 Ksw123.com. All rights reserved.中国考题网 版权所有