From a7dcfdeb814748c6cd0ff66db6bbe90d90155416 Mon Sep 17 00:00:00 2001 From: Peter Petrek Date: Thu, 2 Dec 2021 20:44:15 +0100 Subject: [PATCH] first --- a4/Makefile | 11 ++++++++ a4/program | Bin 0 -> 6471 bytes a4/program.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 a4/Makefile create mode 100755 a4/program create mode 100644 a4/program.c diff --git a/a4/Makefile b/a4/Makefile new file mode 100644 index 0000000..f78f641 --- /dev/null +++ b/a4/Makefile @@ -0,0 +1,11 @@ +# variables +CC=gcc +CFLAGS=-std=c11 -Wall -Werror +LDLIBS=-lm +OUTPUT=$@ + +# targets +%: %.c + $(CC) $(CFLAGS) $@.c $(LDLIBS) -o $(OUTPUT) + + diff --git a/a4/program b/a4/program new file mode 100755 index 0000000000000000000000000000000000000000..aac2250375523f28a2aa925d11ca1c6f11e22051 GIT binary patch literal 6471 zcmb7I4{Te-8NZjf#f;#%Y1s;mz#A^Kh?=wnS|}4qlk^{HDQ#Mqy7F-1m)O*?GyAzT z&_aqGsFy^GN`%UWphyTYEt4wNL9|sUH2uq_EsG|Ev`Q-)u!M%Gtff?2!TbI0-lZ?0 zXxmAj?|%3F?z`{qzPoq6r|RmL8-^itDiXzl$lvMlRwDOYtu&P)AiQFpxIvVQ>8PTv zvI885Y=B17$cGeD2VA)eddN&*3U#zik%?^~yT2s_h3$o3>1Ewdp@ZCm2DK3OOMMZt zKJfdXqg(){P|rRnE5TohzA3f96s=qLksZlhDMT*s@lxbiT>1x~2mD&n_HT>F8gGk7 z7Q|zT%=S<^8Cs-l!!B%jw)B&20uc5+3&Odf{)H!=n}7VfC$`+%);D|Q{`cN} z;umFqq|OI{YvL+M31n&_2Sbx{#ih9d;)SpuOo^Nu_Qk&0UUNI&NlVKwxwtKm0R|uM-06)XMd_Q<$q7)|e41Wwpf8wv}pFQxi`ntcGx7+!ChQ(wa<| zX*-;46%tkYwY!YER8ABEAIj*#Z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Fqv6YD^m{75X_oAhLR$;j>EKj*DHk^lez literal 0 HcmV?d00001 diff --git a/a4/program.c b/a4/program.c new file mode 100644 index 0000000..615b865 --- /dev/null +++ b/a4/program.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include +#define SIZE 100 + +bool jeKopa(int i, int inputNum[SIZE]); + +int main(){ + char stringNum[100]; + int inputNum[100], i = 0; + while (1) + { + //scanf("%s",&stringNum); + fgets(stringNum,SIZE,stdin); + stringNum[strlen(stringNum)-1] = '\0'; + if (!isdigit(stringNum[0])) + { + break; + } + inputNum[i] = atoi(stringNum); + i++; + } + for (int j = (i-1)/2; j >= 0; j--) + { + + } + int vypis[100]; + if(jeKopa(i,inputNum)){ + printf("Je to taka kopa:"); + //int temp = 0, count = 0; + + vypis[0] = 0; + for (int j = 0; j+1 < i; j++) + { + if (2*j+1 >= i) + { + break; + } + vypis[j+1] = 2*j+1; + vypis[i-(j+1)] = 2*j+2; + } + if (i%2==0) + { + vypis[i/2] = inputNum[i-1]; + } + + } + printf("\n"); + + for (int j = 0; j < i; j++) + { + printf("%d, ",inputNum[vypis[j]]); + } + + return 0; +} + +bool jeKopa(int i, int inputNum[SIZE]){ + for (int j = (i-1)/2; j >= 0; j--) + { + int l =2*i+1 , r = 2*i+2; + if (l>=i) + { + continue; + } + if (inputNum[j]>inputNum[l] || inputNum[j]>inputNum[r]) + { + printf("Nieje kopa"); + return 0; + } + + } + + return 1; +} \ No newline at end of file