| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 843 人关注过本帖
标题: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
快速回复:c编程围棋盘代码分析
数据加载中...
 
   



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

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