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; }