From 0503c6bc30ae0aa90a74e1fb8d9cd80e5ef6907d Mon Sep 17 00:00:00 2001 From: Denys Sanchuk Date: Tue, 25 Feb 2025 14:00:04 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20du2/program.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du2/program.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/du2/program.c b/du2/program.c index e69de29..258a4e3 100644 --- a/du2/program.c +++ b/du2/program.c @@ -0,0 +1,33 @@ +#include +#include + +#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; +} \ No newline at end of file