标题:c编程围棋盘代码分析
取消只看楼主
a422105902a
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-6-23
 问题点数:0 回复次数:0 
c编程围棋盘代码分析
各位高手大哥好,我是一个初学者,下面的一个围棋编程代码不懂,希望有人帮忙详细分析一下,qq:422105902
#include <stdio.h>
void main()
{
    int n,m,x,y,temp,j=0,i=0 ;
    printf("输入棋盘的横格数,竖格数:\n");
    scanf("%d,%d",&x,&y);
    printf("%d,%d\n",x,y);
    n=2*x+1 ;
    m=2*y+1 ;
    printf("%d,%d\n",n,m);
    while(j<m)
    {
        j++;
        temp=j%2 ;
        i=0 ;
        if(j==1)
        {
            while(i<n)
            {
                i++;
                if(i==1)
                {
                    printf("__");
                    continue ;
                }
                if(n==i)
                {
                    printf("__\n");
                    continue ;
                }
                if(i%2!=0)
                {
                    printf("__");
                    continue ;
                }
                if(i%2==0)
                {
                    printf("__");
                    continue ;
                }
               
            }
            continue ;
        }
        if(m==j)
        {
            while(i<n)
            {
                i++;
                if(i==1)
                {
                    printf("__");
                    continue ;
                }
                if(n==i)
                {
                    printf("__\n");
                    continue ;
                }
                if(i%2!=0)
                {
                    printf("__");
                    continue ;
                }
                if(i%2==0)
                {
                    printf("__");
                    continue ;
                }
               
            }
            continue ;
        }
        if(temp==0)
        {
            
            while(i<n)
            {
                i++;
                if(i%2!=0)
                {
                    printf("|");
                    if(n==i)printf("\n");
                    continue ;
                }
                if(i%2==0)
                {
      printf("    ");
                    continue ;
                }
               
            }
            continue ;
        }
        if(temp!=0&&j!=1)
        {
            while(i<n)
            {
                i++;
                if(i==1)
                {
                    printf("__");
                    continue ;
                }
                if(n==i)
                {
                    printf("__\n");
                    continue ;
                }
                if(i%2!=0)
                {
                    printf("__");
                    continue ;
                }
                if(i%2==0)
                {
                    printf("__");
                    continue ;
                }
               
            }
            continue ;
        }
    }
}
搜索更多相关主题的帖子: 围棋 代码 
2010-06-23 10:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-311009-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.549012 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved