Update du2/program.c
This commit is contained in:
parent
bf06b29dc9
commit
fb5231595e
@ -3,6 +3,7 @@
|
||||
int main() {
|
||||
double x, koeficient, vysledok = 0;
|
||||
int index = 1;
|
||||
int nacitane;
|
||||
|
||||
// Nacitanie x
|
||||
if (scanf("%lf", &x) != 1) {
|
||||
@ -13,22 +14,22 @@ int main() {
|
||||
// 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
|
||||
return 0;
|
||||
}
|
||||
|
||||
vysledok = koeficient;
|
||||
index++;
|
||||
|
||||
// Čítanie ďalších koeficientov
|
||||
while (scanf("%lf", &koeficient) == 1) {
|
||||
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 (!feof(stdin)) {
|
||||
if (nacitane == 0) {
|
||||
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", index);
|
||||
return 0; // Zmenené z return 1 na return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Vysledok je: %.2f\n", vysledok);
|
||||
|
Loading…
Reference in New Issue
Block a user