What does the following program print?

笔试题一枚。

#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

posted on 2012-02-16 16:35  W@SuperC  阅读(201)  评论(0)    收藏  举报

导航