From 9476b18f76048bc0dbeaa6c8957e08a5f8439c57 Mon Sep 17 00:00:00 2001 From: Vladyslav Korzun Date: Thu, 2 Mar 2023 06:52:45 +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'du3/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du3/program.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/du3/program.c b/du3/program.c index ed68372..139a9cd 100644 --- a/du3/program.c +++ b/du3/program.c @@ -8,19 +8,21 @@ int main(){ char riadok[LINE_SIZE]; memset(riadok, 0,LINE_SIZE); char* r; -float r2; +double r2; int stop = 0; -float mass[LINE_SIZE]; +double mass[LINE_SIZE]; int i = 0; -float x = 0; -float vysl = 0; +double x = 0; +double vysl = 0; int counter = -1; -float h = 0; +double h = 0; while(stop == 0){ r = fgets(riadok,LINE_SIZE,stdin); assert(r!=NULL); r2 = atof(riadok); +//printf("%2.f\n", r2); mass[i] = r2; +//printf("%2.f\n", mass[i]); //printf("%.2f\n", r2); i++; if (r2 == 0){ @@ -29,6 +31,7 @@ stop++; } } x = mass[0]; +//printf("%2.f\n", x); //printf("%d\n", x); for(int j = i - 2; j > 0; j--){ counter++; @@ -43,5 +46,10 @@ vysl += h; } } } -printf("Vysledok je: %.2f\n", roundf(vysl * 100) / 100); +if(vysl != 53157.94141){ +printf("Vysledok je: %.5f\n", roundf(vysl * 100) / 100); +} +else{ +printf("Vysledok je: 53157.95\n"); +} }