Cpp-Primer-5th-Exercises-Chapter-4

Exercise 4.1 1 2 // it's 105. Exercise 4.2 1 2 3 // *vec.begin() equals to *(vec.begin()) // *vec.begin() + 1 equals to (*(vec.begin())) + 1 Exercise 4.3 1 2 // That is acceptable, it is too strict under an orded evaluation order, complier left it blank to allow users to diy, it's more flexible. Exercise 4.4 1 2 3 4 5 6 int main() { int i = 12 / 3 * 4 + 5 * 15 + 24 % 4 / 2; // 91 std::cout << i << std::endl; } Exercise 4.

Cpp-Primer-5th-Exercises-Chapter-3

Exercise 3.2 1 2 3 4 5 6 7 8 9 int main() { string s1, s2; getline(cin, s1); cout << s1 << endl; cin >> s2; cout << s2 << endl; } Exercise 3.3 1 2 3 // std::cin >> string object, space is ignored, words are read in one by one which are separted by space or spaces // getline(std::cin, string object), reads a whole sentence until encounters a '\n', while that '\n' is not sotred in that string object.

Cpp-Primer-5th-Exercises-Chapter-2

Exercise 2.3 1 2 3 4 5 6 7 8 9 10 11 12 13 int main() { unsigned u = 10, u2 = 42; std::cout << u2 - u << std::endl; // 32 std::cout << u - u2 << std::endl; // -32 的二进制补码表示,此次输出该二进制表示被当作无符号数 int

Cpp-Primer-5th-Exercises-Chapter-1

Exercise 1.1 1 2 // Illustration won't be necessary. Exercise 1.2 1 2 3 4 5 int main() { return -1; } Exercise 1.3 1 2 3 4 5 6 int main() { std::cout << "Hello, World." << std::endl; return 0; } Exercise 1.4 1 2 3 4 5 6 7 8 9 10 int main() { std::cout << "Enter two numbers:" << std::endl; int v1 = 0, v2 = 0; std::cin >> v1 >> v2; std::cout << "The product of " << v1 << " and " << v2 << " is " << v1 * v2 << std::endl; return 0; } Exercise 1.

CSAPP-proxylab 解题思路记录

准备 proxy lab 的难度和 malloc lab 不在一个数量级上,主要体现在两个方面: 除了第三部分要实现 cache 以外,前面两部分要求实现 proxy 和 synchronization, 都可以在书上的示例代码中拼凑出来