diff options
Diffstat (limited to 'shortest_path_binary_matrix.c')
-rw-r--r-- | shortest_path_binary_matrix.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/shortest_path_binary_matrix.c b/shortest_path_binary_matrix.c index 20c8d97..f781466 100644 --- a/shortest_path_binary_matrix.c +++ b/shortest_path_binary_matrix.c @@ -91,17 +91,16 @@ int main() { int g1i[2][2] = {{0, 1}, {1, 0}}; int g2i[3][3] = {{0, 0, 0}, {1, 1, 0}, {1, 1, 0}}; int g3i[3][3] = {{1, 0, 0}, {1, 1, 0}, {1, 1, 0}}; - struct two_d_arr g1, g2, g3; - two_d_arr_init(&g1, 2, 2, g1i); - two_d_arr_init(&g2, 3, 3, g2i); - two_d_arr_init(&g3, 3, 3, g3i); - printf("%d\n", shortestPathBinaryMatrix(g1.arr, g1.row_size, - g1.col_size)); // expect: 2 - printf("%d\n", shortestPathBinaryMatrix(g2.arr, g2.row_size, - g3.col_size)); // expect: 4 - printf("%d\n", shortestPathBinaryMatrix(g3.arr, g3.row_size, - g3.col_size)); // expect: -1 - two_d_arr_free(&g1); - two_d_arr_free(&g2); - two_d_arr_free(&g3); + struct two_d_arr *g1 = two_d_arr_init(2, 2, g1i); + struct two_d_arr *g2 = two_d_arr_init(3, 3, g2i); + struct two_d_arr *g3 = two_d_arr_init(3, 3, g3i); + printf("%d\n", shortestPathBinaryMatrix(g1->arr, g1->row_size, + g1->col_size)); // expect: 2 + printf("%d\n", shortestPathBinaryMatrix(g2->arr, g2->row_size, + g3->col_size)); // expect: 4 + printf("%d\n", shortestPathBinaryMatrix(g3->arr, g3->row_size, + g3->col_size)); // expect: -1 + two_d_arr_free(g1); + two_d_arr_free(g2); + two_d_arr_free(g3); } |