who is murderer?

/ *
Japan a place of a murder, the police through the investigation to determine the murderer will be for 4
a suspects. The following is the four suspects confession.
A said: not me.
B said: It is C.
C said: It is D.
D said: C nonsense
known three people told the truth, one person was lying.
Based on this information now, please, write a program to determine in the end who is the murderer.

Idea:
Since it is three people who told the truth a lie to say, then, four of them add up the results of logic value equal to three.
This is probably kill any one of four people, four people will be so again in cycles
if the individual to satisfy this condition which they say a few words, then he should be the murderer.

    四个人说的话可以被表示为      A:  murderer!='A'
                                B:  murderer=='C'
								C:  murderer=='D'
								D:  murderer!='D'

*/


#include<stdio.h>
#include<windows.h>

int main()
{
	int murderer = 0;
	for (murderer = 'A'; murderer <= 'D'; murderer++){
		if (((murderer != 'A')+ (murderer == 'C') + (murderer == 'D') + (murderer != 'D')) == 3){
			printf("murderer = %c\n", murderer);
		}
	}
	system("pause");
	return 0;
}
Published 14 original articles · won praise 0 · Views 146

Guess you like

Origin blog.csdn.net/qq_41041036/article/details/103722856
Recommended