aboutsummaryrefslogtreecommitdiff
path: root/count_unguard_cells_grid.c
diff options
context:
space:
mode:
Diffstat (limited to 'count_unguard_cells_grid.c')
-rw-r--r--count_unguard_cells_grid.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/count_unguard_cells_grid.c b/count_unguard_cells_grid.c
index 17ad819..3b54ebf 100644
--- a/count_unguard_cells_grid.c
+++ b/count_unguard_cells_grid.c
@@ -1,5 +1,6 @@
// 2257. Count Unguarded Cells in the Grid
#include "leetcode.h"
+#include <stdio.h>
/*
* you are given two integers 'm' and 'n' representing a 0-indexed 'm x n' grid.
@@ -68,17 +69,18 @@ int main() {
int g1i[3][2] = {{0, 0}, {1, 1}, {2, 3}},
w1i[3][2] = {{0, 1}, {2, 2}, {1, 4}};
int g2i[1][2] = {{1, 1}}, w2i[4][2] = {{0, 1}, {1, 0}, {2, 1}, {1, 2}};
- struct two_d_arr g1, w1, g2, w2;
- two_d_arr_init(&g1, 3, 2, g1i);
- two_d_arr_init(&w1, 3, 2, w1i);
- two_d_arr_init(&g2, 1, 2, g2i);
- two_d_arr_init(&w2, 4, 2, w2i);
- printf("%d\n", countUnguarded(4, 6, g1.arr, g1.row_size, g1.col_size, w1.arr,
- w1.row_size, w1.col_size)); // expect: 7
- printf("%d\n", countUnguarded(3, 3, g2.arr, g2.row_size, g2.col_size, w2.arr,
- w2.row_size, w2.col_size)); // expect: 4
- two_d_arr_free(&g1);
- two_d_arr_free(&g2);
- two_d_arr_free(&w1);
- two_d_arr_free(&w2);
+ struct two_d_arr *g1 = two_d_arr_init(3, 2, g1i);
+ struct two_d_arr *w1 = two_d_arr_init(3, 2, g1i);
+ struct two_d_arr *g2 = two_d_arr_init(1, 2, g1i);
+ struct two_d_arr *w2 = two_d_arr_init(4, 2, g1i);
+ printf("%d\n",
+ countUnguarded(4, 6, g1->arr, g1->row_size, g1->col_size, w1->arr,
+ w1->row_size, w1->col_size)); // expect: 7
+ printf("%d\n",
+ countUnguarded(3, 3, g2->arr, g2->row_size, g2->col_size, w2->arr,
+ w2->row_size, w2->col_size)); // expect: 4
+ two_d_arr_free(g1);
+ two_d_arr_free(g2);
+ two_d_arr_free(w1);
+ two_d_arr_free(w2);
}