From 8abc55c62b3be1c3ea4a0e7be31348520e1ca1f4 Mon Sep 17 00:00:00 2001 From: Kapliuk Date: Wed, 6 Mar 2024 20:49:43 +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 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index e357001..db85504 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -6,12 +6,14 @@ int main(){ char line[LENGTH]; - int cfIdx, cf1 = 0; + char *y, *chcf; + int cfIdx, cf1, y1,x1,chcf1 = 0; double x, cf,result = 0; - fgets(line, 100, stdin); + fgets(line, 100, stdin); + y = strtok(line,"\n"); x = strtod(line, NULL); - cf1 = ceil(x); - if(cf1 == 0 && line[0] != '\n' && x != 0.0){ + y1 = *y; + if(y1 >= 'A' && line[0] != '\n'){ printf("Nepodarilo sa nacitat zaklad x\n"); return 1; } @@ -19,10 +21,11 @@ int main(){ cfIdx++; result = result * x + cf; fgets(line, 100, stdin); + chcf = strtok(line,"\n"); cf = strtod(line,NULL); - cf1 = ceil(cf); - if(cf1 == 0 && line[0] != '\n' && cf != 0.0){ - printf("\nNepodarilo sa nacitat polynom na %d mieste.\n", cfIdx); + chcf1 = *chcf; + if(chcf1 >='A' && line[0] != '\n'){ + printf("Nepodarilo sa nacitat polynom na %d mieste.\n", cfIdx); return 1; } }