1 A, B, C, D, e Five students are likely to participate in the computer contest, according to the following conditions to determine which (10 points)
Topic content:
A, B, C, D, e Five students are likely to participate in a computer contest, which is judged according to the following conditions
People participated in the contest:
(1) When a participates, B also participates;
(2) B and C only one person participates;
(3) C and D either participate, or neither;
(4) The participation of at least one person in D and E;
(5) If E participates, then both A and D also participate.
Input format:
No
Output format:
Uppercase letters indicate the person who participates, without spaces in the middle.
For example, the end result is that A and d participate, then the output
AD
Coding:
#include <stdio.h>int main () {int a,b,c,d,e;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++) { if (A &&! B) continue; if ((B && C) | | (! B &&! C)) continue; if (C &&! D) | | (! C && D)) continue; if (! D &&! E) continue; if (E && (! A | | ! D)) continue; if (a==1) printf ("A"), if (b==1) printf ("B"), if (c==1) printf ("C"), if (d==1) printf ("D"), if (e==1) printf ("E"); } return 0;}
2, a criminal police brigade of 6 suspects involved in a case analysis: (10 points)
Topic content:
A criminal police brigade on the 6 suspects involved in an analysis of the mystery:
⑴a, b at least 1 people commit crimes;
⑵a, E, F, at least 2 of the 3 persons involved in the crime;
⑷b, C or at the same time, or are not related to the case;
⑸c, D and only one person committing the crime;
⑹ If D did not participate in the crime, then E could not participate in the crime.
Programming to find out who the perpetrator was.
Input format:
Output format:
Uppercase letters indicate the person who participates, without spaces in the middle.
For example, the end result is that A and d participate, then the output
AD
Coding:
#include <stdio.h> int main () {int A, B, C, D, E, F;//define A to e six variables, commit equal to 1, otherwise equal to 0 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++) for (F = 0; F < 2; f++) {if (6 = = (A | | b)//a, b at least one person committed the crime + (!) ( A && D)//a, D cannot be accomplice + ((a && E) | | (A && F) | | (E && F)) A, E, F Three have at least two people involved in the Crime + ((B && C) | | (! B &&! c)//b, C or at the same time, or unrelated to the case + (c &&! D) | | (D &&!) C)//c, D and only one person committed the crime + (d| | (! e))//If D does not participate in the crime, then E is also unlikely to participate in the crime. {if (a==1) printf ("A"), if (b==1) printf ("B"), if (c==1) printf ("C"), if (d==1) printf ("D"), if (e==1) printf ("E"); F (f==1) printf ("F"); }} return 0; }
C Language: Logical reasoning