C 练习实例9

C语言教程评论

C 练习实例9

题目:要求输出国际象棋棋盘。

程序分析:国际象棋棋盘由64个黑白相间的格子组成,分为8行*8列。用i控制行,j来控制列,根据i+j的和的变化来控制输出黑方格,还是白方格。文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili9.html

如果出现乱码情况请参考本博客【C 练习实例7】的解决方法。文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili9.html

实例

#include<stdio.h>

int main()
{
    int i,j;
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
            if((i+j)%2==0)
                printf("%c%c",219,219);
            else printf("  ");
        printf("\n");
    }
    return 0;
}

以上实例输出结果为:文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili9.html

图片说明文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili9.html 文章源自公式库网-https://www.gongshiku.com/html/202112/c-lianxishili9.html

运营不易,
感谢支持!
weinxin
我的微信
我的微信公众号
我的微信公众号扫一扫
weinxin
我的公众号
 最后更新:2021-12-7
公式库网
  • 本文由 公式库网 发表于 2021年12月4日22:56:13
  • 转载请务必保留本文链接:https://www.gongshiku.com/html/202112/c-lianxishili9.html

发表评论