Multidimensional Arrays

Week 3, Multidimensional Arrays Incompatible Representations C语言中多维数组中不兼容表示 参考更多案例: github/c3w3_1.segmentation_fault.c github/c3w3_1.compiler_wrong.c #include <stdio.h> void printArray(int (*arr)[5], int rows) { for (int i = 0; i < rows; ++i) { for (int j = 0; j < 5; ++j) { printf("%d ", arr[i][j]); } printf("\n"); } } int main() { int twoDArray[3][5] = { {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15} }; // 这将有效,因为函数期望一个指向包含5个整数的数组的指针 printArray(twoDArray, 3); return 0; }

2023-12-12 · 1 min · Atom.X

Pointers, Arrays, and Recursion 2

Week 2, Read pointer 2 #include <stdio.h> #include <stdlib.h> int f(int **r, **s){ int temp = **r; int temp2 = **s; int *z = *r; *r = *s; *s = z; printf("**r = %d\n",**r); printf("**s = %d\n",**s); *z += 3; **s -= 8; **r -= 19; return temp + temp2; } int main(void) { int a = 80; int b = 12; int * p = &a; int * q = &b; int x = f(&p, &q); printf("x = %d\n", x); printf("*p = %d\n", *p); printf("*q = %d\n", *q); printf("a = %d\n", a); printf("b = %d\n", b); return EXIT_SUCCESS; } Output **r = 12 **s = 80 x = 92 *p = -7 *q = 75 a = 75 b = -7 ...

2023-12-11 · 1 min · Atom.X

Pointers, Arrays, and Recursion 1

Original Course link: Pointers, Arrays, and Recursion Week 1, Read pointer 1 C pointer C语言指针详解,30分钟玩转C语言指针 (biancheng.net) C语言指针变量的定义和使用(精华)_54笨鸟 (54benniao.com) #include <stdio.h> #include <stdlib.h> void g(int x, int * y) { printf("In g, x = %d, *y = %d\n", x, *y); x++; *y = *y - x; y = &x; } void f(int * a, int b) { printf("In f, *a = %d, b = %d\n", *a, b); *a += b; b *= 2; // * multiply, not pointer identifier here; g(*a, &b); printf("Back in f, *a = %d, b = %d\n", *a, b); } int main(void) { int x = 3; int y = 4; f(&x, y); printf("In main: x = %d, y = %d\n", x, y); return EXIT_SUCCESS; } Output In f, *a = 3, b = 4 In g, x = 7, *y = 8 Back in f, *a = 7, b = 0 In main: x = 7, y = 4 ...

2023-12-10 · 2 min · Atom.X

Programming Testing

Week 3 statement coverage decision coverage path coverage Testing Asserts Black box testing https://www.javatpoint.com/black-box-testing automated tools for black box testing: Selenium: A widely-used open-source testing framework that allows testers to automate the testing of web browsers, making it a valuable tool for performing black box testing on web-based systems. LoadRunner: A performance testing tool that can be used for black box testing of non-functional requirements such as load, stress, and endurance. JMeter: An open-source tool that can be used for black box testing of non-functional requirements such as load, stress, and endurance. SilkTest: A tool that can be used for regression and functionality testing. IBM Rational Functional Tester (RFT): A tool that can be used for creating black box test scripts with a test recorder. GDB manual Debugging with GDB (sourceware.org) ...

2023-12-3 · 2 min · Atom.X

Retirement

Week 2, “retirement savings” calculator Assignment 07_retirement Start Age= 327 months (27 years, 3 months); Savings: 21,345 working 489 months (40 years, 9 months); Savings: 1529340.57 work until Age (68 years, 0 months(-1)) retired 384 months (32 years); Savings: 300234.07 retired until Age(99 years, 11 months(-1), mark every month from 0 - 11 ); Died Age at (100 years, so only compute the 11th month, and don’t compute the last 12th month) ...

2023-11-30 · 4 min · Atom.X