2024-03-07 11:53:07 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define MAX_COEFFICIENTS 100
|
|
|
|
|
|
|
|
double evaluate_polynomial(double x, double coefficients[], int degree) {
|
|
|
|
double result = coefficients[degree];
|
|
|
|
for (int i = degree - 1; i >= 0; i--) {
|
|
|
|
result = result * x + coefficients[i];
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
// Načítanie hodnoty x
|
|
|
|
double x;
|
|
|
|
printf("Zadajte hodnotu x: ");
|
|
|
|
if (scanf("%lf", &x) != 1) {
|
|
|
|
printf("Chyba: Neplatná hodnota x.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Zadefinovanie koeficientov polynómu
|
|
|
|
double coefficients[] = {57.0};
|
|
|
|
int degree = 1;
|
|
|
|
|
|
|
|
// Vyhodnotenie polynómu pre danú hodnotu x
|
|
|
|
double result = evaluate_polynomial(x, coefficients, degree - 1);
|
|
|
|
|
|
|
|
// Výpis výsledku
|
|
|
|
printf("Výsledok: %.2f\n", result);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|