2024-03-03 21:24:56 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main() {
|
2024-03-03 21:37:25 +00:00
|
|
|
float pole[50];
|
2024-03-03 21:24:56 +00:00
|
|
|
int opakovania = 0;
|
2024-03-05 17:57:34 +00:00
|
|
|
float cislo = 0;
|
|
|
|
float skenovanie;
|
|
|
|
int zla_hodnota = 0;
|
|
|
|
int zly_index = -1;
|
2024-03-03 21:24:56 +00:00
|
|
|
|
2024-03-03 21:37:25 +00:00
|
|
|
while (opakovania < 50) {
|
2024-03-05 17:57:34 +00:00
|
|
|
skenovanie = scanf("%f", &cislo);
|
|
|
|
|
|
|
|
if (skenovanie == 1) {
|
|
|
|
pole[opakovania] = cislo;
|
|
|
|
opakovania++;
|
|
|
|
} else if (skenovanie == EOF) {
|
|
|
|
if (zla_hodnota) {
|
2024-03-05 17:58:55 +00:00
|
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", zly_index);
|
2024-03-05 18:00:16 +00:00
|
|
|
return 0;
|
2024-03-05 17:57:34 +00:00
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
zla_hodnota = 1;
|
|
|
|
zly_index = opakovania;
|
|
|
|
while (getchar() != '\n');
|
2024-03-03 21:24:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-05 17:57:34 +00:00
|
|
|
if (opakovania == 0) {
|
|
|
|
printf("Nepodarilo sa nacitat hodnotu X.\n");
|
2024-03-05 18:00:16 +00:00
|
|
|
return 0;
|
2024-03-05 17:57:34 +00:00
|
|
|
}
|
2024-03-03 21:24:56 +00:00
|
|
|
|
2024-03-05 17:57:34 +00:00
|
|
|
float vysledok = pole[1];
|
2024-03-03 21:24:56 +00:00
|
|
|
for (int i = 2; i < opakovania; ++i) {
|
2024-03-03 21:34:20 +00:00
|
|
|
vysledok = vysledok * pole[0] + pole[i];
|
2024-03-03 21:24:56 +00:00
|
|
|
}
|
|
|
|
|
2024-03-03 21:34:20 +00:00
|
|
|
printf("Vysledok je: %.2f\n", vysledok);
|
2024-03-03 21:24:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|