设为首页 加入收藏

TOP

C语言之围棋(利用队列实现)(四)
2023-07-23 13:30:37 】 浏览:198
Tags:利用队
nbsp;       chess[x+1][y]=twtype;

        num--;

              }

             

        if(chess[x][y-1]==type){

             r=(lqnode *)malloc(sizeof(lqnode));

        r->x=x;

        r->y=y-1;

        q->rear->next=r;

        r->next=null;

        q->rear=r;

        chess[x][y-1]=twtype;

        num--;

              }

             

             

      

        if(chess[x][y+1]==type){

             r=(lqnode *)malloc(sizeof(lqnode));

        r->x=x;

        r->y=y+1;

        q->rear->next=r;

        r->next=null;

        q->rear=r;

        chess[x][y+1]=twtype;

        num--;

              }

       if(num==4){

              break;再判断一遍,找不到就退出

       }

       t=t->next;

       x=t->x;

       y=t->y;

       printf("%d,%d\n",x,y);

}

 

t=q->front->next;//先记录一下这个头

       int count=0;

       printf("该块有以下元素:\n");

    while(q->rear!=q->front){

             lqnode *s;

             s=q->front->next;

             x=s->x;

             y=s->y;

     //上下左右都找一遍,注意条件,有些在边上,比如【0】【0】这个点x-1是找不到的

             if(chess[x+1][y]==0 && x+1>=0 && y>=0){

                     count++;

 &nbs

首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C 语言实现一个简单通讯录 下一篇驱动开发:内核监控Register注册..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目