This commit is contained in:
Džubara 2024-02-28 15:46:06 +01:00
parent c2421587e8
commit ff0c230282

View File

@ -8,9 +8,7 @@
bool IsValidNumber(const char *line) {
char *endFtr;
strtod(line, &endFtr);
if (endFtr == line){
return false;
}
return endFtr != line;
}
int main() {
@ -26,6 +24,9 @@ int main() {
while (1) {
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
if (line[0] == '\n') {
break;
}
printf("Nepodarilo sa nacitat polynom na %d mieste. \n", coefficientIndex);
return 1;
}
@ -38,7 +39,7 @@ int main() {
}
result = result * x;
coefficientIndex++;
coefficientIndex++;
}
printf("Vysledok je: %.2f\n", result);