43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
float pole[50];
|
|
int opakovania = 0;
|
|
float cislo = 0;
|
|
char line[100];
|
|
int validny = 1;
|
|
|
|
while (opakovania < 50) {
|
|
if (fgets(line, sizeof(line), stdin) != NULL) {
|
|
if (sscanf(line, "%f", &cislo) == 1) {
|
|
pole[opakovania] = cislo;
|
|
opakovania++;
|
|
} else if (line[0] == '\n') {
|
|
break;
|
|
} else {
|
|
if (opakovania == 0) {
|
|
printf("Nepodarilo sa nacitat zaklad x.\n");
|
|
return 0;
|
|
}
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", opakovania);
|
|
opakovania = 0;
|
|
validny = 0;
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (validny) {
|
|
float vysledok = pole[1];
|
|
for (int i = 2; i < opakovania; ++i) {
|
|
vysledok = vysledok * pole[0] + pole[i];
|
|
}
|
|
|
|
printf("Vysledok je: %.2f\n", vysledok);
|
|
}
|
|
|
|
return 0;
|
|
}
|