adding solution to exercise 3
This commit is contained in:
@@ -404,7 +404,7 @@ c->y[1] = 7;
|
|||||||
b = NULL;
|
b = NULL;
|
||||||
```
|
```
|
||||||
|
|
||||||
See [solution](memory_exercise1_solution.png)
|
See [solution](memory_exercise1_solution.png).
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
int a[5] = { 10, 11, 12, 13, 14 };
|
int a[5] = { 10, 11, 12, 13, 14 };
|
||||||
@@ -416,8 +416,10 @@ c[1] = b[1];
|
|||||||
c = &(a[3]);
|
c = &(a[3]);
|
||||||
```
|
```
|
||||||
|
|
||||||
See [solution](memory_exercise2_solution.png)
|
See [solution](memory_exercise2_solution.png).
|
||||||
|
|
||||||
- Write code to produce this diagram:
|
- Write code to produce this diagram:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
See [solution](memory_exercise3_solution.cpp).
|
||||||
|
|||||||
8
lectures/06_memory/memory_exercise3_solution.cpp
Normal file
8
lectures/06_memory/memory_exercise3_solution.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
double a[3];
|
||||||
|
double *b = new double[3];
|
||||||
|
a[0] = 4.2;
|
||||||
|
a[1] = 8.6;
|
||||||
|
a[2] = 2.9;
|
||||||
|
b[0] = 6.5;
|
||||||
|
b[1] = 5.1;
|
||||||
|
b[2] = 3.4;
|
||||||
Reference in New Issue
Block a user