From 05f7a22103ef8a5c2ee3e3345754a77980b4c0fc Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 19 Nov 2024 15:23:54 +0100 Subject: [PATCH] Initializacia --- a4/program.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 a4/program.c diff --git a/a4/program.c b/a4/program.c new file mode 100644 index 0000000..899e543 --- /dev/null +++ b/a4/program.c @@ -0,0 +1,34 @@ +#include +#include + +int is_heap(int* arr, int size ){ + for(int i = 0; i < size; i++){ + int l = i * 2 + 1; + int r = i * 2 + 2; + } + + if (left < size && arr[i] < arr[left]){ + return 0; + } + + if (right < size && arr[i] < arr[right]){ + return 0; + } + return 1; +} + +int main() { + int arr[] = 100; + int size = 0; + + while (scanf("%d", &num) != EOF){ + arr[size++] = num; + } + + if (!is_heap(arr, size)){ + printf("Nie je kopa."); + } + + return 0; +} +