您的位置:首页 > 其它

What does the following program print?

2012-02-16 16:35 323 查看
笔试题一枚。

#include <iostream>
#include <vector>
using namespace std;

void print(vector<int>);

int main(int argc, char* argv[])
{
int x=2,y,z;
x *= (y=z=5);
cout << x << endl;
z=3;
x ==(y=z); //y=z=3,x未变
cout << x << endl;
x = (y==z); //y==z为真,
cout << x << endl;
x = (y&z);
cout << x << endl;
x = (y&&z);
cout << x << endl;
y = 4;
x = (y|z);
cout << x << endl;
x = (y||z);
cout << x << endl;

return 0;
}

answer:10,10,1,3,1,7,1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: