题目:张三说李四在说谎,李四说王五在说谎,王五说张三和李四都在说谎。现在问:这三人中到底谁说的是真话,谁说的是假话?
//题目:张三说李四在说谎,李四说王五在说谎,王五说张三和李四都在说谎。
//现在问:这三人中到底谁说的是真话,谁说的是假话?
//BY as1138 2011-04-02
#include <iostream>
using namespace std;
int main(void)
{
int a,b,c;
bool tem = false;
for(a = 1; a >= 0;--a)
for(b = 1; b >= 0;--b)
for(c = 1; c >= 0;--c)
if ((a+b==1)&&(b+c==1)&&(a+b+c==1))
{
cout<<"张三"<<(a?"没说谎":"说谎")<<endl;
cout<<"李四"<<(b?"没说谎":"说谎")<<endl;
cout<<"王五"<<(c?"没说谎":"说谎")<<endl;
tem = true;
}
if (!tem)
{
cout<<"三个人都说谎了!"<<endl;
}
return 1;
}