usaa24/a4/program.c

39 lines
555 B
C
Raw Normal View History

2024-11-19 22:18:54 +00:00
#include <stdio.h>
2024-11-23 20:22:13 +00:00
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:23:40 +00:00
printf("%d\n", a[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:30:08 +00:00
2024-11-19 22:18:54 +00:00
return 0;
}