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