From 72e86465e0d6ef2ec644e803bcd0353a8102a7e3 Mon Sep 17 00:00:00 2001 From: Anzhelika Nikolaieva Date: Tue, 7 Mar 2023 21:39:43 +0000 Subject: [PATCH] Update 'du3/program.c' --- du3/program.c | 66 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/du3/program.c b/du3/program.c index a0c2508..ba2820f 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,24 +1,54 @@ #include -#include +#include #include +#include +#include +#include + +#define VELKOST_POLA 50 -#define VELKOST_POLA 52 int main(){ - int x[6], i, j, k; - int a[6] = {3, 5, 2, 4, 1, 6}; - printf("Enter the values of x: \n"); -for(i = 0; i < 6; i++){ - scanf("%d", &x[i]); -} -int y = 0; -for(j = 5; j >= 0; j--){ - k = 1; -for(i = 0; i < j; i++){ - k = k*x[i]; -} -y = y + a[j]*k; -} + int a = 0; + char r[SIZE]; + memset(r, 0, SIZE); + char* stav_r = fgets(r, SIZE, stdin); + bool x0 = true; -printf("y = %d\n", y); -return 0; + if (stav_r == NULL){ + break; + } + if (x0 = true){ + x[a] = strtof(r); + } + if (r[0] == '\n'){ + x0 = false; + } + if (pipa(r[0])){ + if (a < 1 && n > -1){ + printf("Nepodarilo sa nacitat zaklad x\n" ); + break; + } + printf"Nepodarilo sa nacitat polynom na %d mieste.\n", a); + break; + } + if (x0 = true){ + a = a+1; + } + if (a == 2){ + printf("Vysledok je: %.2f\n", x[1]); + return 0; + } +long int b; +b = x[0]; +long int c; +c = x[1]; +long int results = 0; +int d = 0; + while (d < a-2){ + d++; + results = b*c+x[d+1]; + c = results; + } + printf("Vysledok: %.2f\n", results); + return 0; }