schema
This commit is contained in:
parent
ebdb1ceaac
commit
5619d453a3
@ -8,7 +8,9 @@
|
||||
bool IsValidNumber(const char *line) {
|
||||
char *endFtr;
|
||||
strtod(line, &endFtr);
|
||||
return *endFtr == '\0';
|
||||
if (endPtr == line){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
@ -23,7 +25,6 @@ int main() {
|
||||
}
|
||||
|
||||
while (1) {
|
||||
printf("Zadajte polynom na %d mieste: ", coefficientIndex);
|
||||
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
|
||||
printf("Nepodarilo sa nacitat polynom na %d mieste. \n", coefficientIndex);
|
||||
return 1;
|
||||
@ -36,11 +37,10 @@ int main() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = result * x;
|
||||
coefficientIndex++;
|
||||
result = result * x + coeffiecientIndex;
|
||||
}
|
||||
|
||||
printf("Vysledok je: %f\n", result);
|
||||
printf("Vysledok je: %.2f\n", result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user