You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/solutions/collections/2darrays.md
+32-4Lines changed: 32 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ tags:
65
65
| 40 | 50 | 60 |
66
66
| 70 | 80 | 90 |
67
67
68
-
<details>
68
+
<details>
69
69
<summary>Solution</summary>
70
70
71
71
```
@@ -112,6 +112,14 @@ tags:
112
112
By using the `Length` field: `temp.Length` is the number of elements in the `temp` array.
113
113
We can also compute the product of `temp.GetLength(0)` and `temp.GetLength(1)`.
114
114
</details>
115
+
116
+
#. Write a `Display` static method that takes as an argument a 2-dimensional array and displays it at the screen.
117
+
118
+
<details>
119
+
<summary>Solution</summary>```
120
+
!include`snippetStart="// Method to display 2-d arrays", snippetEnd="// End of method to display 2-d arrays"` code/snippets/2darrays.cs
121
+
```
122
+
</details>
115
123
116
124
#. Write a program that display "Every row contains its own index" if the 2-dimensional rectangular array of `int``matrix` is such that its first row contains the value 0, its second row contains the value 1, etc.
117
125
@@ -172,6 +180,26 @@ tags:
172
180
```
173
181
</details>
174
182
183
+
#. Write a program that "rotate" a 2-dimensional array 90° clockwise. For example, the array
184
+
185
+
```
186
+
!include`snippetStart="// Example array1", snippetEnd="// End of example array1"` code/snippets/2darrays.cs
187
+
```
188
+
189
+
would become
190
+
191
+
```text
192
+
| 10 | 7 | 4 | 1 |
193
+
| 11 | 8 | 5 | 2 |
194
+
| 12 | 9 | 6 | 3 |
195
+
```
196
+
197
+
<details>
198
+
<summary>Solution</summary>```
199
+
!include`snippetStart="// Method to rotate an array 90° clockwise", snippetEnd="// End of method to rotate an array 90° clockwise"` code/snippets/2darrays.cs
200
+
```
201
+
</details>
202
+
175
203
## Problem: Toward a Crossword Puzzle Solver
176
204
177
205
The goal of this problem is to work toward the creation of a program that solve crossword puzzles.
@@ -191,9 +219,9 @@ Test your program thoroughly, possibly bundling it in a `static` class to ease t
191
219
<details>
192
220
<summary>Solution</summary>
193
221
A possible implementation, as a static class, is as follows:
0 commit comments