From fc8b19653c1cdd5cfa93e35ab1693f6e69608dde Mon Sep 17 00:00:00 2001 From: Michal Utlak Date: Sun, 3 Mar 2024 22:24:56 +0100 Subject: [PATCH] skuska --- cv3/program.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/cv3/program.c b/cv3/program.c index cb58d7b..56484d2 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1 +1,27 @@ -roiew +#include + +int main() { + float pole[20]; + int opakovania = 0; + float cislo; + + while (opakovania < 20) { + if (scanf("%f", &cislo) == EOF) { + break; + } + pole[opakovania] = cislo; + opakovania++; + } + + float result = pole[1]; + + for (int i = 2; i < opakovania; ++i) { + result = result * pole[0] + pole[i]; + } + + result = ((int)(result * 100 + 0.5)) / 100.0; + + printf("Vysledok je: %.2f\n", result); + + return 0; +}