程序员面试宝典_程序设计基本概念

来源:互联网 发布:android app 端口号 编辑:程序博客网 时间:2024/05/17 22:52

eg1.   题目: 下列C++代码的输出结果是什么

#include <iostream>using namespace std;int i = 1;int main(){int i = i;return 0;}

答案:

../demo1.cpp:13: 警告:此函数中的‘i’在使用前未初始化

eg2.    题目:下列程序的输出结果是什么

#include <iostream>using namespace std;int main(){int x = 2, y, z;x *= (y = z = 5);cout << x << endl;z = 3;x == (y = z);cout << x << endl;x = (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;}
答案:

10,10,1,3,1,7,1


原创粉丝点击