Five if conditions correspond to five conditions respectively.

Source: Internet
Author: User

/* A group selects A number of views from the following areas: A, B, C, D, and E:
1) If you want to remove A, you must go to B;
2) D and E can only go to one location;
3) B and C can only go to one location;
4) C. D. Neither go nor go;
5) if you go to E, A and D will also go.
Where can the group go at most?
*/
[Cpp]
# Include "stdio. h"
# Include "stdlib. h"
# Include "time. h"
Int main ()
{Int a, B, c, d, e;
Int x [5];
For (a = 0; a <2; a ++)
For (B = 0; B <2; B ++)
For (c = 0; c <2; c ++)
For (d = 0; d <2; d ++)
For (e = 0; e <2; e ++)
{// Five if conditions correspond to five conditions respectively
If (a & B | (a = 0 & B = 0 ))
If (d + e <2)
If (B + c <2)
If (c & d)
If (e & a & d | (e = 0 ))
{X [0] = a; x [1] = B; x [2] = c; x [3] = d; x [4] = e;
For (int I = 0; I <5; I ++)
If (x [I])
Printf ("% c will be arrived \ n", 'A' + I );
}}
Printf ("\ n ");
System ("pause ");
}

# Include "stdio. h"
# Include "stdlib. h"
# Include "time. h"
Int main ()
{Int a, B, c, d, e;
Int x [5];
For (a = 0; a <2; a ++)
For (B = 0; B <2; B ++)
For (c = 0; c <2; c ++)
For (d = 0; d <2; d ++)
For (e = 0; e <2; e ++)
{// Five if conditions correspond to five conditions respectively
If (a & B | (a = 0 & B = 0 ))
If (d + e <2)
If (B + c <2)
If (c & d)
If (e & a & d | (e = 0 ))
{X [0] = a; x [1] = B; x [2] = c; x [3] = d; x [4] = e;
For (int I = 0; I <5; I ++)
If (x [I])
Printf ("% c will be arrived \ n", 'A' + I );
}}
Printf ("\ n ");
System ("pause ");
} // Of course, only x [0] ~ can be used. X [4]. Here a, B, c, d, and e are used for intuition and convenience only.

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.