# Simple Logical Judgement

Posted by jcornett on Wed, 01 Jul 2020 18:23:37 +0200

# Title 1

Five athletes participated in the 10m platform diving competition and were asked to predict the result
Player A said: B second, I third;
Player B said: I'm second, E fourth;
Player C said: I am the first, D the second;
Player D said: C In the end, I am third;
Player E said: I am fourth, A first;
After the game, each player said half right. Please program to determine the place in the competition.

```#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
//Player A said: B second, I third;
//Player B said: I'm second, E fourth;
//Player C said: I am the first, D the second;
//Player D said: C In the end, I am third;
//Player E said: I am fourth, A first;
int main()
{
int A = 0, B = 0, C = 0, D = 0, E = 0;
for (A = 1; A <= 5; A++)
for (B = 1; B <= 5; B++)
for (C = 1; C <= 5; C++)
for (D = 1; D <= 5; D++)
for (E = 1; E <= 5; E++)
{
if ((B == 2) + (A == 3) == 1)
if ((B == 2) + (E == 4) == 1)
if ((C == 1) + (D == 2) == 1)
if ((C == 5) + (D == 3) == 1)
if ((E == 4) + (A == 1) == 1)
break;
}
printf("A:No.%d B:No.%d C:No.%d D:No.%d E:No.%d\n", A, B, C, D, E);
system("pause");
return 0;

}```

# Title 2

A murder case has occurred somewhere in Japan, and police have investigated it to make sure that the murderer must be four suspects
One of them.The following are the confessions of four suspects.
A said: Not me.
B said: Yes, C.
C said: Yes, D.
D said: C is talking nonsense
Three people are known to have spoken the truth and one is known to be false.
Now, based on this information, write a program to determine who the murder is.

```#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
//A said: Not me.
//B said: Yes, C.
//C said: Yes, D.
//D said: C is talking nonsense
int main()
{
char killer = 0;
for (killer = 'a'; killer <= 'd'; killer++)
if (3 == (killer != 'a') + (killer == 'c') + (killer == 'd') + (killer != 'd'))
break;
printf("killer is %c\n", killer);
system("pause");
return 0;
}```