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;
|
2024-03-05 22:46:22 +00:00
|
|
|
char line[100];
|
|
|
|
int validny = 1;
|
2024-03-03 21:24:56 +00:00
|
|
|
|
2024-03-03 21:37:25 +00:00
|
|
|
while (opakovania < 50) {
|
2024-03-05 22:46:22 +00:00
|
|
|
if (fgets(line, sizeof(line), stdin) != NULL) {
|
|
|
|
if (sscanf(line, "%f", &cislo) == 1) {
|
|
|
|
pole[opakovania] = cislo;
|
|
|
|
opakovania++;
|
|
|
|
} else if (line[0] == '\n') {
|
|
|
|
break;
|
2024-03-05 17:57:34 +00:00
|
|
|
} else {
|
2024-03-05 22:46:22 +00:00
|
|
|
if (opakovania == 0) {
|
2024-03-05 22:47:30 +00:00
|
|
|
printf("Nepodarilo sa nacitat zaklad x\n");
|
2024-03-05 22:46:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
printf("Nepodarilo sa nacitat polynom na %d mieste.\n", opakovania);
|
|
|
|
opakovania = 0;
|
|
|
|
validny = 0;
|
2024-03-05 17:57:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2024-03-05 22:46:22 +00:00
|
|
|
break;
|
2024-03-03 21:24:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-05 22:46:22 +00:00
|
|
|
if (validny) {
|
|
|
|
float vysledok = pole[1];
|
|
|
|
for (int i = 2; i < opakovania; ++i) {
|
|
|
|
vysledok = vysledok * pole[0] + pole[i];
|
|
|
|
}
|
2024-03-03 21:24:56 +00:00
|
|
|
|
2024-03-05 22:46:22 +00:00
|
|
|
printf("Vysledok je: %.2f\n", vysledok);
|
2024-03-03 21:24:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|