# The beauty of programming--1.2 Chinese chess Generals problem

Source: Internet
Author: User
`#include <iostream>using namespace std;//set some computed macro typedef char bytes; #define BYTES_LENGTH 255//A byte data size # define Bytes_half_length 4//Half-byte digits//#define RHALF (bytes_length>>bytes_half_length)//Right half for 00001111#define RHALF 15// #define LHALF (Bytes_length<<bytes_half_length)//left half is 11110000#define lhalf 240#define stored_r (b,n) (B= (n| ( b&lhalf))//to deposit N to the right half of B # # stored_l (b,n) (b= ((n<<bytes_half_length) | ( b&rhalf))//Add N to the left half of B # # Get_r (b) (b&rhalf)//Get the right four-bit # # of B get_l (b) ((b&lhalf) >>bytes_ Half_length)//Get the left of B four-bit # define Mov_with 3//The moving width of the chess piece int main () {bytes b=0;for (stored_r (b,1); Get_r (b) <=MOV_WITH*MOV_WITH; Stored_r (B,get_r (b) +1)) {for (stored_l (b,1); get_l (b) <=MOV_WITH*MOV_WITH; Stored_l (b,get_l (b) +1)) {if (Get_r (b)%mov_with!=get_l (b)%mov_with) {Cout<<get_r (b) << ' <<get_l (b ) <<endl;}}} System ("pause"); return 1;}`

The beauty of programming--1.2 Chinese chess Generals problem

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.