这是在采访中被问到的。以下代码段的输出是什么?
#include <iostream>
using namespace std;
int main() {
cout << (3,2,1)-(1,2,3) << endl; // in C++ too this prints -2
printf("%d\n",(3,2,1)-(1,2,3)); // prints -2
printf("%d\n",("%d",3,2,1)-(1,2,3)); // prints -2
return 0;
}
通过输出,我猜测它的 (1-3) = -2。但是如何从(3,2,1)
价值1
中选择,同样从(1,2,3)
价值3
中选择?我的猜测是否正确?