From 711c7beb56a17671b5052a61f3a7a952ced09cb2 Mon Sep 17 00:00:00 2001 From: Peter Petrek Date: Fri, 3 Dec 2021 09:22:28 +0100 Subject: [PATCH] last --- a4/program.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/a4/program.c b/a4/program.c index 6237821..9392537 100644 --- a/a4/program.c +++ b/a4/program.c @@ -39,6 +39,7 @@ int main(){ } printf("\n"); + vypisovac(vypis,inputNum,i+1); return 0; } @@ -62,9 +63,41 @@ 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; + int counter = 0, count = ownPow(2,0), space = 0, i = 1, lastRow, indexLast = 0, next = 0; + while (ownPow(2,i)<= size){ + i++; + } + lastRow = (-1)*((ownPow(2,i-1)-1) - size); + indexLast = i-1; + if (lastRow == 0) + { + lastRow = (ownPow(2,i-1)-1); + indexLast = i-2; + } + i = 0; for (i = 0; i < size; i++) { + while (space == indexLast) + { + counter++; + for (int k = 0; k < space; k++) + { + printf(" "); + } + printf("%d\n",input[vypis[(int)i]]); + if (counter>=count) + { + next = 1; + break; + } + + } + if (next) + { + next = 0; + continue; + } + if (counter>=count && i<=(size/2)) { count = ownPow(2,i)/2;