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; } }