aboutsummaryrefslogtreecommitdiff
path: root/rotting_oranges.c
diff options
context:
space:
mode:
Diffstat (limited to 'rotting_oranges.c')
-rw-r--r--rotting_oranges.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/rotting_oranges.c b/rotting_oranges.c
index f59eff9..83d6bb3 100644
--- a/rotting_oranges.c
+++ b/rotting_oranges.c
@@ -72,15 +72,16 @@ int orangesRotting(int **grid, int gridSize, int *gridColSize) {
int main() {
int g1i[3][3] = {{2, 1, 1}, {1, 1, 0}, {0, 1, 1}},
g2i[3][3] = {{2, 1, 1}, {1, 1, 0}, {0, 1, 1}}, g3i[1][2] = {{0, 2}};
- struct two_d_arr g1, g2, g3;
- two_d_arr_init(&g1, 3, 3, g1i);
- two_d_arr_init(&g2, 3, 3, g2i);
- two_d_arr_init(&g3, 1, 2, g3i);
- printf("%d\n", orangesRotting(g1.arr, g1.row_size, g1.col_size)); // expect: 4
- printf("%d\n", orangesRotting(g2.arr, g2.row_size, g2.col_size)); // expect:
- // -1
- printf("%d\n", orangesRotting(g3.arr, g3.row_size, g3.col_size)); // expect: 0
- two_d_arr_free(&g1);
- two_d_arr_free(&g2);
- two_d_arr_free(&g3);
+ struct two_d_arr *g1 = two_d_arr_init(3, 3, g1i);
+ struct two_d_arr *g2 = two_d_arr_init(3, 3, g2i);
+ struct two_d_arr *g3 = two_d_arr_init(1, 2, g3i);
+ printf("%d\n",
+ orangesRotting(g1->arr, g1->row_size, g1->col_size)); // expect: 4
+ printf("%d\n",
+ orangesRotting(g2->arr, g2->row_size, g2->col_size)); // expect: -1
+ printf("%d\n",
+ orangesRotting(g3->arr, g3->row_size, g3->col_size)); // expect: 0
+ two_d_arr_free(g1);
+ two_d_arr_free(g2);
+ two_d_arr_free(g3);
}