中国象棋将帅问题

#include<stdio.h>  

int main()
{
    struct{
        unsigned char a:4;
        unsigned char b:4;
    }i;
    
    for (i.a = 1; i.a <= 9; i.a++) {
        for (i.b = 1; i.b <= 9; i.b++) {
            if (i.a % 3 != i.b % 3) {
                printf("A = %d, B = %d\n", i.a, i.b);
            }
        }
    }

    return 0;
}


output:

A = 1, B = 2

A = 1, B = 3

A = 1, B = 5

A = 1, B = 6

A = 1, B = 8

A = 1, B = 9

A = 2, B = 1

A = 2, B = 3

A = 2, B = 4

A = 2, B = 6

A = 2, B = 7

A = 2, B = 9

A = 3, B = 1

A = 3, B = 2

A = 3, B = 4

A = 3, B = 5

A = 3, B = 7

A = 3, B = 8

A = 4, B = 2

A = 4, B = 3

A = 4, B = 5

A = 4, B = 6

A = 4, B = 8

A = 4, B = 9

A = 5, B = 1

A = 5, B = 3

A = 5, B = 4

A = 5, B = 6

A = 5, B = 7

A = 5, B = 9

A = 6, B = 1

A = 6, B = 2

A = 6, B = 4

A = 6, B = 5

A = 6, B = 7

A = 6, B = 8

A = 7, B = 2

A = 7, B = 3

A = 7, B = 5

A = 7, B = 6

A = 7, B = 8

A = 7, B = 9

A = 8, B = 1

A = 8, B = 3

A = 8, B = 4

A = 8, B = 6

A = 8, B = 7

A = 8, B = 9

A = 9, B = 1

A = 9, B = 2

A = 9, B = 4

A = 9, B = 5

A = 9, B = 7

A = 9, B = 8



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值