37 lines
935 B
C
37 lines
935 B
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
double x, koeficient, vysledok = 0;
|
|
int index = 1;
|
|
|
|
// Nacitanie x
|
|
if (scanf("%lf", &x) != 1) {
|
|
printf("Nepodarilo sa nacitat zaklad x.\n");
|
|
return 0;
|
|
}
|
|
|
|
// Nacitanie prvého koeficientu
|
|
if (scanf("%lf", &koeficient) != 1) {
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", index);
|
|
return 0; // Zmenené z return 1 na return 0
|
|
}
|
|
|
|
vysledok = koeficient;
|
|
index++;
|
|
|
|
// Čítanie ďalších koeficientov
|
|
while (scanf("%lf", &koeficient) == 1) {
|
|
vysledok = vysledok * x + koeficient;
|
|
index++;
|
|
}
|
|
|
|
// Ak posledné čítanie zlyhalo a nebol to EOF, znamená to nečíselný vstup
|
|
if (!feof(stdin)) {
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", index);
|
|
return 0; // Zmenené z return 1 na return 0
|
|
}
|
|
|
|
printf("Vysledok je: %.2f\n", vysledok);
|
|
return 0;
|
|
}
|