From e6c2f23cc6f9d3e15ffee34fb3cec6ba1ad58196 Mon Sep 17 00:00:00 2001 From: Oleksandr Hryshchenko Date: Fri, 22 Oct 2021 11:37:46 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'cv3/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv3/program.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 23ac35d..1c5748f 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -48,13 +48,13 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){ temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) / atof(buffer[currentlyInBuffer-1]))*100)/100; } - for(int i = currentlyInBuffer-3; currentlyInBuffer > i; currentlyInBuffer--) - memset(buffer[currentlyInBuffer], SIZE, '\0'); + for(int i = currentlyInBuffer-2; currentlyInBuffer > i; currentlyInBuffer--) + memset(buffer[currentlyInBuffer], '\0', SIZE); gcvt(temporaryDecimal, 10, buffer[currentlyInBuffer++]); - for(int i = 0; i <= currentlyInBuffer; i++){ - if(i == currentlyInBuffer) + for(int i = 0; i < currentlyInBuffer; i++){ + if(i == currentlyInBuffer-1) printf("%0.2f \n", roundf(atof(buffer[i]) * 100) / 100); else printf("%0.2f ", roundf(atof(buffer[i]) * 100) / 100); @@ -64,6 +64,7 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){ } else{ printf("bad input\n"); + return false; } } @@ -80,4 +81,4 @@ int main() { printf("no input\n"); return 0; -} +} \ No newline at end of file