This commit is contained in:
Jana Kapalková 2026-03-05 18:24:12 +01:00
parent 3e96d3a32c
commit 37f855b52a

View File

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