diff options
author | Jack Sangdahl <[email protected]> | 2025-08-27 12:45:33 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-08-27 12:45:33 -0600 |
commit | 4552bcf5a4a356415e248dee3b201f0cea7205bb (patch) | |
tree | 9868465918c6a6841b84cd14d66923b993dd9d62 /transform_to_chessboard.c | |
parent | f549305fb5ca531d29dce6c2c091560f44190443 (diff) | |
download | leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.tar.gz leetcode-4552bcf5a4a356415e248dee3b201f0cea7205bb.zip |
chore: Refactor two_d_arr_init function
Return a pointer to a new struct, rather than initialise objects in an
existing struct
Diffstat (limited to 'transform_to_chessboard.c')
-rw-r--r-- | transform_to_chessboard.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/transform_to_chessboard.c b/transform_to_chessboard.c index efe2031..8bd9f08 100644 --- a/transform_to_chessboard.c +++ b/transform_to_chessboard.c @@ -41,17 +41,16 @@ int main() { int b1i[4][4] = {{0, 1, 1, 0}, {0, 1, 1, 0}, {1, 0, 0, 1}, {1, 0, 0, 1}}; int b2i[2][2] = {{0, 1}, {1, 0}}; int b3i[2][2] = {{1, 0}, {1, 0}}; - struct two_d_arr b1, b2, b3; - two_d_arr_init(&b1, 4, 4, b1i); - two_d_arr_init(&b2, 2, 2, b2i); - two_d_arr_init(&b3, 2, 2, b3i); + struct two_d_arr *b1 = two_d_arr_init(4, 4, b1i); + struct two_d_arr *b2 = two_d_arr_init(2, 2, b2i); + struct two_d_arr *b3 = two_d_arr_init(2, 2, b3i); printf("%d\n", - movesToChessboard(b1.arr, b2.row_size, b3.col_size)); // expect: 2 + movesToChessboard(b1->arr, b2->row_size, b3->col_size)); // expect: 2 printf("%d\n", - movesToChessboard(b2.arr, b2.row_size, b2.col_size)); // expect: 0 + movesToChessboard(b2->arr, b2->row_size, b2->col_size)); // expect: 0 printf("%d\n", - movesToChessboard(b3.arr, b3.row_size, b3.col_size)); // expect: -1 - two_d_arr_free(&b1); - two_d_arr_free(&b2); - two_d_arr_free(&b3); + movesToChessboard(b3->arr, b3->row_size, b3->col_size)); // expect: -1 + two_d_arr_free(b1); + two_d_arr_free(b2); + two_d_arr_free(b3); } |