From d9d4265e6849feb3cd6aaa2f3c9f1b1704994bb6 Mon Sep 17 00:00:00 2001 From: Yaroslav Orlianskyi Date: Fri, 18 Mar 2022 12:51:17 +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 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/du3/program.c b/du3/program.c index 9013cdc..375aced 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,22 +1,24 @@ #include int main(){ - char riadok[999]; float vxod[999]; int i = 0; + int a = 1; float result = 0; while(1){ - - int* r = *fgets(riadok,999,stdin); - if(*r != '\n') - vxod[i++] = *r; - /*else if(*r <= 255 && *r >= 0){ + float value = 0; + float r = scanf("%f", &value); + if(r == 1) + vxod[i++] = value; + else if(r <= 255 && r >= 0){ if(i != 0) printf("Nepodarilo sa nacitat polynom na %d mieste.\n", i); else printf("Nepodarilo sa nacitat zaklad x\n"); break; - }*/else{ + }else{ + for(a = 1; a < i; a++) + printf("%.2f\n", vxod[a]); for(int a = 1; a < i; a++) result = vxod[0] * result + vxod[a]; printf("Vysledok je: %.2f\n", result); @@ -24,4 +26,4 @@ int main(){ } } return 0; -} +} \ No newline at end of file