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