Update a4/program.c

This commit is contained in:
Yurii Yakovenko 2024-11-23 20:32:19 +00:00
parent 909a9286f8
commit f27c6383c4

View File

@ -1,5 +1,23 @@
#include <stdio.h>
///
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;
}