diff --git a/a4/program b/a4/program index c00ea40..9d4e350 100755 Binary files a/a4/program and b/a4/program differ diff --git a/a4/program.c b/a4/program.c index 84f96ef..fdfee9f 100644 --- a/a4/program.c +++ b/a4/program.c @@ -3,29 +3,20 @@ #include #include #include +#include + #define SIZE 100 bool jeKopa(int i, int inputNum[SIZE]); - +void vypisovac(int vypis[SIZE], int input[SIZE], int size); +int ownPow(int base, int power); +int input(char string[100], int numbers[100]); 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 inputNum[100] = {0}, i = 0; + fgets(stringNum,SIZE,stdin); + i = input(stringNum,inputNum) -1; + for (int j = 0; j < SIZE; j++){if(inputNum[j]<0-1){i++;}} int vypis[100]; if(jeKopa(i,inputNum)){ printf("Je to taka kopa:"); @@ -48,20 +39,7 @@ int main(){ } printf("\n"); - int count = 0; - for (int j = 0; j < i-1; j++) - { - if (j<=(i)/2) - { - for (int k = 0; k < count; k++) - { - printf(" "); - } - count++; - } - printf("%d\n",inputNum[vypis[j]]); - } - + vypisovac(vypis,inputNum,i); return 0; } @@ -73,7 +51,7 @@ bool jeKopa(int i, int inputNum[SIZE]){ { continue; } - if (inputNum[j]>inputNum[l] || inputNum[j]>inputNum[r]) + if ((inputNum[j]>inputNum[l]) || (inputNum[j]>inputNum[r])) { printf("Nieje kopa"); return 0; @@ -82,4 +60,58 @@ bool jeKopa(int i, int inputNum[SIZE]){ } return 1; +} +void vypisovac(int vypis[SIZE], int input[SIZE], int size){ + int counter = 0, count = ownPow(2,0), space = 0, i = 0; + for (i = 0; i < size; i++) + { + if (counter>=count && (i)<=(size/2)) + { + count = ownPow(2,i)/2; + counter = 0; + space++; + } + else if ((counter>=count && (i)>(size/2)) || vypis[i]0) + { + result = 1; + } + else{ + return 1; + } + + for (int i = 0; i