From f194279a0ca5f1748baec2af37e7883b071484f0 Mon Sep 17 00:00:00 2001 From: Vladyslav Korzun Date: Wed, 1 Mar 2023 15:43:11 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'du3/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du3/program.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/du3/program.c b/du3/program.c index 6f839b3..50d6f17 100644 --- a/du3/program.c +++ b/du3/program.c @@ -2,22 +2,46 @@ #include #include #include +#include #define LINE_SIZE 10 int main(){ char riadok[LINE_SIZE]; memset(riadok, 0,LINE_SIZE); -char* r = fgets(riadok,LINE_SIZE,stdin); -assert(r!=NULL); -int r2 = atol(riadok); +char* r; +int r2; int stop = 0; +char mass[LINE_SIZE]; +int i = 0; +int x = 0; +int vysl = 0; +int counter = -1; +int h = 0; +while(stop == 0){ +r = fgets(riadok,LINE_SIZE,stdin); +assert(r!=NULL); +r2 = atol(riadok); +mass[i] = r2; +//printf("%d\n", r2); +i++; if (r2 == 0){ - printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula."); + //printf("Konverzia sa nepodarila alebo v reťazci sa nachádza nula.\n"); stop++; } -if(stop == 0){ -printf("%d", r2); - } - - +x = mass[0]; +//printf("%d\n", x); +for(int j = i - 2; j > 0; j--){ +counter++; +h = mass[j]; +//printf("%d ", h); +if(j != 0){ +if(counter != 0){ +vysl += h * pow(x,counter); +} +else{ +vysl += h; +} +} +} +printf("Vysledok je:%d\n", vysl); }