From 38fcde55b5e9763fd3edd98d870f6cb50317d56b Mon Sep 17 00:00:00 2001 From: Vladyslav Korzun Date: Mon, 6 Mar 2023 18:51:03 +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 | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/du3/program.c b/du3/program.c index 1c84182..ced3a6e 100644 --- a/du3/program.c +++ b/du3/program.c @@ -20,19 +20,19 @@ int main(){ int pos = -1; //float p = 0; while(stop == 0){ - if(feof(stdin)){ - break; - } r = fgets(riadok,LINE_SIZE,stdin); pos++; - if(feof(stdin)){ - break; - } - if (r == NULL || !isdigit(*r)) { + if (r == NULL || !isdigit(*r) || feof(stdin)) { //printf("%d", *r); if(*r == 10){ stop = 1; } + if(feof(stdin)){ + stop = 1; + r2 = atof(riadok); + mass[i] = r2; + i++; + } else{ if(pos > 0){ printf("Nepodarilo sa nacitat polynom na %d mieste.\n", pos); @@ -52,20 +52,20 @@ int main(){ } x = mass[0]; vysl = x; - //printf("%d\n", x); + printf("x>>>>>%1.f\n", x); if(i != 3 || mass[1] == 4){ for(int j = 1; j < i - 1; j++){ h = mass[j]; - //printf("h>>> %1.f\n", h); + printf("h>>> %1.f\n", h); if(counter == -1){ vysl = x * h + mass[j + 1]; - //printf("vysl>>> %1.f\n", vysl); + printf("vysl>>> %1.f\n", vysl); counter++; } else{ if(j != i - 2){ vysl = x * vysl + mass[j + 1]; - //printf("vysl22>>>>> %1.f\n", vysl); + printf("vysl22>>>>> %1.f\n", vysl); } } } @@ -73,10 +73,5 @@ int main(){ else{ vysl = mass[1]; } - if(vysl == 6.58){ - printf("Vysledok je: 10.84"); - } - else{ printf("Vysledok je: %.2f\n", vysl); } -}