diff --git a/cv3/program.c b/cv3/program.c index bef5560..e69de29 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,47 +0,0 @@ -#include -#include - -#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() { - int degree; - printf("Zadajte stupeň polynómu: "); - if (scanf("%d", °ree) != 1 || degree < 0) { - printf("Chyba: Neplatný stupeň polynómu.\n"); - return 1; - } - - if (degree >= MAX_COEFFICIENTS) { - printf("Chyba: Príliš vysoký stupeň polynómu.\n"); - return 1; - } - - double coefficients[MAX_COEFFICIENTS]; - printf("Zadajte koeficienty polynómu: "); - for (int i = 0; i <= degree; i++) { - if (scanf("%lf", &coefficients[i]) != 1) { - printf("Chyba: Neplatný koeficient polynómu.\n"); - return 1; - } - } - - double x; - printf("Zadajte hodnotu x: "); - if (scanf("%lf", &x) != 1) { - printf("Chyba: Neplatná hodnota x.\n"); - return 1; - } - - double result = evaluate_polynomial(x, coefficients, degree); - printf("Výsledok je: %.2f\n", result); - - return 0; -}