正文
增加 15 行删除 15 行
188 行未改动全部展开18919019119219319419519619719819920020120220320420520612 行未改动21922022122222322422522622722822923023123223323423523623723823924024122 行未改动26426526626726826927027127227327427527627727827928028120 行未改动30230330430530630730830931059 行未改动37037137237337437537637737850 行未改动42943043143243343443543643748 行未改动486487488489490491492493494495496497498499500127 行未改动全部展开62862963063163263363463563687 行未改动7247257267277287297307317324 行未改动188 行未改动全部展开long long b = 1e18;double c = 3.14159;char d = 'A';bool e = true;// 算术运算符int sum = a + 5;int mod = a % 3; // 10 % 3 = 1// 位运算符int bit_and = a & 3; // 1010 & 0011 = 0010 (2)int bit_or = a | 3; // 1010 | 0011 = 1011 (11)int left_shift = a << 1; // 1010 << 1 = 10100 (20)cout << "sum: " << sum << ", mod: " << mod << endl;return 0;}```12 行未改动cout << "Negative" << endl;} else {cout << "Zero" << endl;}// for循环for (int i = 0; i < 5; i++) {cout << i << " ";}cout << endl;// while循环int j = 0;while (j < 5) {cout << j << " ";j++;}cout << endl;// switch-caseint day = 3;switch (day) {case 1: cout << "Monday"; break;22 行未改动int main() {// 一维数组int nums[5] = {1, 2, 3, 4, 5};cout << "Sum: " << arraySum(nums, 5) << endl;// 二维数组int matrix[2][3] = {{1, 2, 3}, {4, 5, 6}};for (int i = 0; i < 2; i++) {for (int j = 0; j < 3; j++) {cout << matrix[i][j] << " ";}cout << endl;}// 字符串操作string s = "Hello";s += " World";cout << s << ", length: " << s.length() << endl;20 行未改动int *p = &x; // 指针指向x的地址cout << "x = " << x << ", *p = " << *p << endl;*p = 20; // 通过指针修改x的值cout << "x = " << x << endl;// 引用示例int a = 5, b = 10;swap(a, b);cout << "a = " << a << ", b = " << b << endl; // 输出10,559 行未改动cout << st.top() << " "; // 3 2 1st.pop();}cout << endl;// 队列(FIFO)queue<int> q;q.push(1);q.push(2);50 行未改动root->left = new TreeNode(2);root->right = new TreeNode(3);root->left->left = new TreeNode(4);root->left->right = new TreeNode(5);cout << "Preorder: "; preorder(root); cout << endl; // 1 2 4 5 3cout << "Inorder: "; inorder(root); cout << endl; // 4 2 5 1 3cout << "Postorder: "; postorder(root); cout << endl;// 4 5 2 3 1return 0;48 行未改动adj[0].push_back(2);adj[1].push_back(3);adj[1].push_back(4);adj[2].push_back(4);// DFSvisited.assign(n, false);cout << "DFS: ";dfs(0); // 0 1 3 4 2cout << endl;// BFSvisited.assign(n, false);cout << "BFS: ";bfs(0); // 0 1 2 3 4127 行未改动全部展开int main() {vector<int> a = {1, 2, 3, 4, 5};cout << "区间[2,4]的和:" << prefixSum(a, 2, 4) << endl; // 2+3+4=9rangeAdd(a, 2, 4, 10); // 区间[2,4]各元素加10for (int x : a) {cout << x << " "; // 1 12 13 14 5}87 行未改动vector<int> a, b;// 字符串转逆序数字数组for (int i = sa.size()-1; i >= 0; i--) a.push_back(sa[i] - '0');for (int i = sb.size()-1; i >= 0; i--) b.push_back(sb[i] - '0');vector<int> c = add(a, b);reverse(c.begin(), c.end()); // 逆序后输出for (int x : c) {cout << x; // 123456 + 7890 = 1313464 行未改动188 行未改动全部展开18919019119219319419519619719819920020120220320420520612 行未改动21922022122222322422522622722822923023123223323423523623723823924024122 行未改动26426526626726826927027127227327427527627727827928028120 行未改动30230330430530630730830931059 行未改动37037137237337437537637737850 行未改动42943043143243343443543643748 行未改动486487488489490491492493494495496497498499500127 行未改动全部展开62862963063163263363463563687 行未改动7247257267277287297307317324 行未改动188 行未改动全部展开long long b = 1e18;double c = 3.14159;char d = 'A';bool e = true;// 算术运算符int sum = a + 5;int mod = a % 3; // 10 % 3 = 1// 位运算符int bit_and = a & 3; // 1010 & 0011 = 0010 (2)int bit_or = a | 3; // 1010 | 0011 = 1011 (11)int left_shift = a << 1; // 1010 << 1 = 10100 (20)cout << "sum: " << sum << ", mod: " << mod << endl;return 0;}```12 行未改动cout << "Negative" << endl;} else {cout << "Zero" << endl;}// for循环for (int i = 0; i < 5; i++) {cout << i << " ";}cout << endl;// while循环int j = 0;while (j < 5) {cout << j << " ";j++;}cout << endl;// switch-caseint day = 3;switch (day) {case 1: cout << "Monday"; break;22 行未改动int main() {// 一维数组int nums[5] = {1, 2, 3, 4, 5};cout << "Sum: " << arraySum(nums, 5) << endl;// 二维数组int matrix[2][3] = {{1, 2, 3}, {4, 5, 6}};for (int i = 0; i < 2; i++) {for (int j = 0; j < 3; j++) {cout << matrix[i][j] << " ";}cout << endl;}// 字符串操作string s = "Hello";s += " World";cout << s << ", length: " << s.length() << endl;20 行未改动int *p = &x; // 指针指向x的地址cout << "x = " << x << ", *p = " << *p << endl;*p = 20; // 通过指针修改x的值cout << "x = " << x << endl;// 引用示例int a = 5, b = 10;swap(a, b);cout << "a = " << a << ", b = " << b << endl; // 输出10,559 行未改动cout << st.top() << " "; // 3 2 1st.pop();}cout << endl;// 队列(FIFO)queue<int> q;q.push(1);q.push(2);50 行未改动root->left = new TreeNode(2);root->right = new TreeNode(3);root->left->left = new TreeNode(4);root->left->right = new TreeNode(5);cout << "Preorder: "; preorder(root); cout << endl; // 1 2 4 5 3cout << "Inorder: "; inorder(root); cout << endl; // 4 2 5 1 3cout << "Postorder: "; postorder(root); cout << endl;// 4 5 2 3 1return 0;48 行未改动adj[0].push_back(2);adj[1].push_back(3);adj[1].push_back(4);adj[2].push_back(4);// DFSvisited.assign(n, false);cout << "DFS: ";dfs(0); // 0 1 3 4 2cout << endl;// BFSvisited.assign(n, false);cout << "BFS: ";bfs(0); // 0 1 2 3 4127 行未改动全部展开int main() {vector<int> a = {1, 2, 3, 4, 5};cout << "区间[2,4]的和:" << prefixSum(a, 2, 4) << endl; // 2+3+4=9rangeAdd(a, 2, 4, 10); // 区间[2,4]各元素加10for (int x : a) {cout << x << " "; // 1 12 13 14 5}87 行未改动vector<int> a, b;// 字符串转逆序数字数组for (int i = sa.size()-1; i >= 0; i--) a.push_back(sa[i] - '0');for (int i = sb.size()-1; i >= 0; i--) b.push_back(sb[i] - '0');vector<int> c = add(a, b);reverse(c.begin(), c.end()); // 逆序后输出for (int x : c) {cout << x; // 123456 + 7890 = 1313464 行未改动