usaa24/a4/program.c

39 lines
549 B
C
Raw Normal View History

2024-11-19 22:18:54 +00:00
#include <stdio.h>
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-19 22:30:08 +00:00
printf("Je to taka kopa:");
2024-11-23 20:18:11 +00:00
printf("%d", a[0]);
}
2024-11-19 22:30:08 +00:00
else
printf("Nie je kopa.");
2024-11-19 22:18:54 +00:00
return 0;
}