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
#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
相关文章推荐
- hnu 13052 What does the fox say?
- What does the collation influence the database ?
- What does the C ??!??! operator do?!
- The ServiceClass object does not implement the required method in the following form: OMElement sayH
- What does the “yield” keyword do? (转)
- And that’s what the lowest level of the Libevent API does for you
- What does the lic…
- What does the number on the visual studio solution icon represent?
- Why does Python print unicode characters when the default encoding is ASCII?
- What does it mean to be an Open Source author? A story from the inside
- UVaLive 6581 && Gym 100299B What does the fox say? (模拟+STL)
- What does the first letter "c" mean in "calloc"?
- Mongoose - What does the exec function do?
- BNU Online Judge-34776-What does the fox say?
- VS 安装助手,弹出“The security key for this program currently stored on your system does not appear to be ”
- 053-19 What recommendations does the SQL Access Advisor provide for optimizing SQL queries? (Choose
- 802.11 WDS how does it work, when to use it and what are the limitations
- Programming Basic--what is the output of the following code?
- What is the computer program?
- What does the three dots in react do?