aboutsummaryrefslogtreecommitdiff
path: root/count_square_submatrices_ones.c
diff options
context:
space:
mode:
Diffstat (limited to 'count_square_submatrices_ones.c')
-rw-r--r--count_square_submatrices_ones.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/count_square_submatrices_ones.c b/count_square_submatrices_ones.c
index 34c8d51..a517ad1 100644
--- a/count_square_submatrices_ones.c
+++ b/count_square_submatrices_ones.c
@@ -19,11 +19,12 @@ int countSquares(int **matrix, int matrixSize, int *matrixColSize) {
int main() {
int m1i[3][4] = {{0, 1, 1, 1}, {1, 1, 1, 1}, {0, 1, 1, 1}},
m2i[3][3] = {{1, 0, 1}, {1, 1, 0}, {1, 1, 0}};
- struct two_d_arr m1, m2;
- two_d_arr_init(&m1, 4, 3, m1i);
- two_d_arr_init(&m2, 3, 3, m2i);
- printf("%d\n", countSquares(m1.arr, m1.row_size, m2.col_size)); // expect: 15
- printf("%d\n", countSquares(m2.arr, m2.row_size, m2.col_size)); // expect: 7
- two_d_arr_free(&m1);
- two_d_arr_free(&m2);
+ struct two_d_arr *m1 = two_d_arr_init(4, 3, m1i);
+ struct two_d_arr *m2 = two_d_arr_init(3, 3, m2i);
+ printf("%d\n",
+ countSquares(m1->arr, m1->row_size, m2->col_size)); // expect: 15
+ printf("%d\n",
+ countSquares(m2->arr, m2->row_size, m2->col_size)); // expect: 7
+ two_d_arr_free(m1);
+ two_d_arr_free(m2);
}