Q:甲说:乙说谎; 乙说:丙说谎;丙说:甲乙两人都说谎。到底谁说谎?谁没有说谎?

 

#include"stdio.h"
	
int main() {
	int a,b,c;
	for(a=0;a<=1;a++)
		for(b=0;b<=1;b++)
			for(c=0;c<=1;c++)
			if((a&&!b || !a&&b) &&(b&&!c || !b&&c) &&(c&&a+b==0 || !c&&a+b!=0))
				{
					printf("甲 told a %s\n",a?"truth" : "lie");
					printf("乙 told a %s\n",b?"truth" : "lie");
					printf("丙 told a %s\n",c?"truth" : "lie");
					break;
					
				}
	return 0;
}

  

posted on 2017-05-04 14:42  王小东大将军  阅读(155)  评论(0编辑  收藏  举报