Обновить du2/program.c
This commit is contained in:
parent
5d5ef40bac
commit
0503c6bc30
@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define MAX_SIZE 50
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
double x, coefficient, result = 0.0;
|
||||||
|
int count = 0;
|
||||||
|
double coefficients[MAX_SIZE];
|
||||||
|
|
||||||
|
if (scanf("%lf", &x) != 1) {
|
||||||
|
printf("Chyba: Hodnota pre x nebola nacitana.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (count < MAX_SIZE && scanf("%lf", &coefficient) == 1) {
|
||||||
|
coefficients[count++] = coefficient;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
printf("Chyba: Koeficient nebol nacitany.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = coefficients[0];
|
||||||
|
for (int i = 1; i < count; i++) {
|
||||||
|
result = result * x + coefficients[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Vysledok je: %.2lf\n", result);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user