aboutsummaryrefslogtreecommitdiff
path: root/find_max_sum_node_val.c
diff options
context:
space:
mode:
Diffstat (limited to 'find_max_sum_node_val.c')
-rw-r--r--find_max_sum_node_val.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/find_max_sum_node_val.c b/find_max_sum_node_val.c
index 6005bc7..8c5b5bb 100644
--- a/find_max_sum_node_val.c
+++ b/find_max_sum_node_val.c
@@ -29,17 +29,19 @@ int main() {
int n2[] = {2, 3}, e2i[1][2] = {{0, 1}};
int n3[] = {7, 7, 7, 7, 7, 7},
e3i[5][2] = {{0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}};
- struct two_d_arr e1, e2, e3;
- two_d_arr_init(&e1, ARRAY_SIZE(e1i), ARRAY_SIZE(e1i[0]), e1i);
- two_d_arr_init(&e1, ARRAY_SIZE(e1i), ARRAY_SIZE(e1i[0]), e1i);
- two_d_arr_init(&e1, ARRAY_SIZE(e1i), ARRAY_SIZE(e1i[0]), e1i);
- printf("%lld\n", maximumValueSum(n1, ARRAY_SIZE(n1), 3, e1.arr, e1.row_size,
- e1.col_size)); // expect: 6
- printf("%lld\n", maximumValueSum(n2, ARRAY_SIZE(n2), 7, e2.arr, e2.row_size,
- e2.col_size)); // expect: 9
- printf("%lld\n", maximumValueSum(n3, ARRAY_SIZE(n3), 3, e3.arr, e3.row_size,
- e3.col_size)); // expect: 42
- two_d_arr_free(&e1);
- two_d_arr_free(&e2);
- two_d_arr_free(&e3);
+ struct two_d_arr *e1 =
+ two_d_arr_init(ARRAY_SIZE(e1i), ARRAY_SIZE(e1i[0]), e1i);
+ struct two_d_arr *e2 =
+ two_d_arr_init(ARRAY_SIZE(e2i), ARRAY_SIZE(e2i[0]), e2i);
+ struct two_d_arr *e3 =
+ two_d_arr_init(ARRAY_SIZE(e3i), ARRAY_SIZE(e3i[0]), e3i);
+ printf("%lld\n", maximumValueSum(n1, ARRAY_SIZE(n1), 3, e1->arr, e1->row_size,
+ e1->col_size)); // expect: 6
+ printf("%lld\n", maximumValueSum(n2, ARRAY_SIZE(n2), 7, e2->arr, e2->row_size,
+ e2->col_size)); // expect: 9
+ printf("%lld\n", maximumValueSum(n3, ARRAY_SIZE(n3), 3, e3->arr, e3->row_size,
+ e3->col_size)); // expect: 42
+ two_d_arr_free(e1);
+ two_d_arr_free(e2);
+ two_d_arr_free(e3);
}