C + + code: bit operation instance (bit operation example)

Source: Internet
Author: User

A task needs to be completed in the five persons of a, B, C, D, E, but the person is limited to the following conditions:

(1) If a goes, then B goes with it.

(2) D,e two people will go

(3) B,c Two people will go, but only one person

(4) C,d either go, or neither.

(5) If e goes, then A and B will go to

Analysis:

For this example of logic judgment, we get the logical expression of the condition, and we have the solution mode of the logic judgment class. If each person's go and not to be seen as a 5-bit integer in which 1, where a pair with the highest level, E corresponds to the lowest bit, then all the possible redeployment scheme is from all the non-assigned 00000 to all of the 11111 changes between the pi. Clearly, there are 32 scenarios in which all loops are:

The descendants of a, B, C, D, E are then entered into the expression, that is, the program can be constituted:

C + + code: bit operation instance (bit operation example)

Related Article

Contact Us

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.