我碰到這個謎語前幾天來到爲什麼(1 <1 <1)在C++中返回true?
main()
{
cout << (1 < 1 < 1 ? "true" : "false") << endl;
}
我不能想通了,爲什麼在地球上,則返回true。我期待假的。
更:
cout << (2 < 2 < 2 ? "true" : "false") << endl; // returns true
cout << (0 < 0 < 0 ? "true" : "false") << endl; // returns false
cout << (-1 < -1 < -1 ? "true" : "false") << endl; // returns false
cout << (-2 < -2 < -2 ? "true" : "false") << endl; // returns false
它似乎返回值嚴格大於0,否則爲false更大如此。
任何人都有對此的解釋?由於事先
我確定這是一個重複的問題。但是這是因爲(1 <1)<1'爲真,並且'(0 <0)<0'爲假。由於'1 <1'爲假,'false <1'爲真。 –
我記得聽說過一種語言,其中x
john
@john可能是python。 – juanchopanza