56 lines
834 B
C
56 lines
834 B
C
#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;
|
|
|
|
do
|
|
{
|
|
if(scanf("%d", &a[i])!=1)
|
|
break;
|
|
else
|
|
i++;
|
|
|
|
}while(1);
|
|
|
|
int kupa=1;
|
|
int n=i;
|
|
|
|
for(int i=0; i<n; i++)
|
|
{
|
|
if(2*i+1<n && a[i]>a[2*i+1]||
|
|
2*i+2<n && a[i]>a[2*i+2])
|
|
{
|
|
kupa =0;
|
|
break;
|
|
}
|
|
}
|
|
if(kupa)
|
|
{
|
|
printf("Je to taka kopa:\n");
|
|
print(a, n, 0, 0);
|
|
}
|
|
else
|
|
printf("Nie je kopa.\n");
|
|
|
|
return 0;
|
|
}
|