3632 - 谁在撒谎?
猫说狗在撒谎。
狗说猪在撒谎。
猪说猫狗都在撒谎。
请编程找出到底谁在撒谎?
Input
Output
假如猫狗猪都撒谎了,应输出000
Examples
Input
Output
Solution C++
#include <iostream> using namespace std; int a[3]; void f(int idx) { if(idx==3) { if((a[0]!=a[1])&&(a[1]!=a[2])&&(a[2]==1&&(a[0]+a[1])==0||a[2]==0&&(a[0]+a[1])!=0)) { for(int i=0;i<3;i++) cout<<a[i]; cout<<endl; } return; } a[idx]=0; f(idx+1); a[idx]=1; f(idx+1); } int main() { f(0); return 0; }