From f27c6383c41e99fbe02bf39764e8265f26e70887 Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Sat, 23 Nov 2024 20:32:19 +0000 Subject: [PATCH] Update a4/program.c --- a4/program.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/a4/program.c b/a4/program.c index 8e990c0..1815814 100644 --- a/a4/program.c +++ b/a4/program.c @@ -1,5 +1,23 @@ #include -/// + + +void print(int *a, int n, int index, int depth) +{ + if (index >= n) + return; + + for (int i = 0; i < depth; i++) + { + printf(" "); + } + printf("%d\n", a[index]); + + print(a, n, 2 * index + 1, depth + 1); + print(a, n, 2 * index + 2, depth + 1); +} + + + int main() { int a[1000], i=0; @@ -28,11 +46,10 @@ int main() if(kupa) { printf("Je to taka kopa:\n"); - printf("%d\n", a[0]); + print(a, n, 0, 0); } else printf("Nie je kopa.\n"); - return 0; }