1
This commit is contained in:
parent
69f09317a0
commit
1ba46cee88
@ -13,19 +13,16 @@ double evaluate_polynomial(double x, double coefficients[], int degree) {
|
||||
|
||||
int main() {
|
||||
double x;
|
||||
|
||||
// Načítanie hodnoty x zo štandardného vstupu
|
||||
if (scanf("%lf", &x) != 1) {
|
||||
printf("Chyba: Neplatná hodnota x.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Načítanie koeficientov polynómu
|
||||
|
||||
double coefficients[MAX_COEFFICIENTS];
|
||||
int degree;
|
||||
|
||||
printf("Zadajte stupeň polynómu: ");
|
||||
if (scanf("%d", °ree) != 1) {
|
||||
if (scanf("%d", °ree) != 1 || degree < 0 || degree >= MAX_COEFFICIENTS) {
|
||||
printf("Chyba: Neplatný stupeň polynómu.\n");
|
||||
return 1;
|
||||
}
|
||||
@ -38,10 +35,7 @@ int main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Vyhodnotenie polynómu pre zadanú hodnotu x
|
||||
double result = evaluate_polynomial(x, coefficients, degree);
|
||||
|
||||
// Výpis výsledku
|
||||
printf("Vysledok je: %.2f\n", result);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user