2024-11-19 22:18:54 +00:00
|
|
|
#include <stdio.h>
|
2024-11-23 20:32:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-19 22:18:54 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int a[1000], i=0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(scanf("%d", &a[i])!=1)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
i++;
|
|
|
|
|
|
|
|
}while(1);
|
|
|
|
|
2024-11-19 22:30:08 +00:00
|
|
|
int kupa=1;
|
|
|
|
int n=i;
|
|
|
|
|
|
|
|
for(int i=0; i<n; i++)
|
2024-11-19 22:18:54 +00:00
|
|
|
{
|
2024-11-19 22:30:08 +00:00
|
|
|
if(2*i+1<n && a[i]>a[2*i+1]||
|
2024-11-23 20:18:11 +00:00
|
|
|
2*i+2<n && a[i]>a[2*i+2])
|
2024-11-19 22:30:08 +00:00
|
|
|
{
|
2024-11-23 20:18:11 +00:00
|
|
|
kupa =0;
|
2024-11-19 22:30:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-11-19 22:18:54 +00:00
|
|
|
}
|
2024-11-19 22:30:08 +00:00
|
|
|
if(kupa)
|
2024-11-23 20:18:11 +00:00
|
|
|
{
|
2024-11-23 20:22:02 +00:00
|
|
|
printf("Je to taka kopa:\n");
|
2024-11-23 20:32:19 +00:00
|
|
|
print(a, n, 0, 0);
|
2024-11-23 20:18:11 +00:00
|
|
|
}
|
2024-11-19 22:30:08 +00:00
|
|
|
else
|
2024-11-23 20:22:02 +00:00
|
|
|
printf("Nie je kopa.\n");
|
2024-11-19 22:18:54 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|