diff --git a/du1/program.c b/du1/program.c index 5a768e5..8195c4b 100644 --- a/du1/program.c +++ b/du1/program.c @@ -12,20 +12,20 @@ int main() { char* r = NULL; double x = 0, val = 0, result = 0; int first = 1; - int count = 0; + int count = 1; memset(line, 0, LINE_SIZE); r = fgets(line, LINE_SIZE, stdin); if (r == NULL) { printf("Nepodarilo sa nacitat hodnotu x.\n"); - return 1; + return 0; } assert(r != NULL); x = strtod(line, &endptr); if (line == endptr) { printf("Nepodarilo sa nacitat hodnotu x.\n"); - return 1; + return 0; } while (fgets(line, LINE_SIZE, stdin) != NULL) { if (strlen(line) <= 1 && (line[0] == '\n' || line[0] == '\r')) { @@ -34,10 +34,11 @@ int main() { char *ptr = line; while (isspace((unsigned char)*ptr)) ptr++; if (*ptr == '\0') break; - val = strtod(line, &endptr); - if (line == endptr) { - printf("Nepodarilo sa nacitat koeficient %d.\n", count); - return 1; + + val = strtod(ptr, &endptr); + if (ptr == endptr) { + printf("Nepodarilo sa nacitat polynom na %d mieste.\n", count); + return 0; } if (first) { result = val;