From b93a837ae50ca3baf6174648da88c86a5761c99d Mon Sep 17 00:00:00 2001 From: Kapliuk Date: Wed, 6 Mar 2024 18:19:50 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BD=D0=BE=D0=B2=D0=B8=D1=82=D0=B8=20'c?= =?UTF-8?q?v3/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv3/program.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 96b43dc..300b4ce 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,21 +1,30 @@ #include #include #include -#include -#include -#define MAX_I_LINE_LENGTH 256 +#define LENGTH 256 + int main(){ - char line[MAX_I_LINE_LENGTH]; - int cfIdx = 0; + char line[LENGTH]; + int cfIdx, cf1 = 0; double x, cf,result = 0; - fgets(line, 100, stdin); + fgets(line, 100, stdin); x = strtod(line, NULL); + cf1 = x; + if(cf1 == 0 && line[0] != '\n'){ + printf("Nepodarilo sa nacitat zaklad x\n"); + return 1; + } while(line[0] != '\n'){ + cfIdx++; result = result * x + cf; fgets(line, 100, stdin); cf = strtod(line,NULL); + cf1 = cf; + if(cf1 == 0 && line[0] != '\n'){ + printf("\nNepodarilo sa nacitat polynom na %d mieste.\n", cfIdx); + return 1; + } } printf("Vysledok je: %.2f\n", result); return 0; - } \ No newline at end of file