C++ Primer Answer ch04
4.1 #include <iostream> using namespace std; int main() { cout << 5 + 10 * 20 / 2;//105 return 0; } 4.2 #include <iostream> #include <vector> using namespace std; int main() { vector<int> vec = {1, 3, 5}; cout << *vec.begin() << ' '; cout << *(vec.begin()) << ' '; cout << *vec.begin() + 1 << ' '; cout << (*(vec.begin())) + 1; return 0; } 4.3 可以。操作数的求解顺序通常对结果没什么影响,只有当二元操作符的两个操作数涉及同一对象,并改变对象的值时,操作数的求解顺序才会影响计算结果。实现效率的提高能使使用编译器的程序受益。 4.4 #include <iostream> using namespace std; int main() { cout << 12 / 3 * 4 + 5 * 15 + 24 % 4 / 2;//91 return 0; } 4.5 #include <iostream> using namespace std; int