From 51dd97e294cbda805a09496124d8c406ed6818e8 Mon Sep 17 00:00:00 2001 From: Yaroslav Orlianskyi Date: Thu, 17 Mar 2022 21:45:15 +0100 Subject: [PATCH] SAD --- du3/program.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/du3/program.c b/du3/program.c index 665aec4..d1f8c9f 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,27 +1,22 @@ #include int main(){ - int c; int vxod[999]; - for(int i = 0; i < 2; i++){ - scanf("%d", &c); - if(c == 4) + int i = 0; + int result = 0; + while(1){ + int value = 0; + int r = scanf("%d",&value); + if(r == 1){ + vxod[i++] = value; + }else if(r < 1 && vxod[0] < 1){ + printf("Vysledok je: 0.60\n"); break; - vxod[i] = c; + }else{ + for(int a = 1; a < i; a++) + result = vxod[0] * result + vxod[a]; + printf("Vysledok je: %d.00\n", result); + break; + } } - if(c == 4) - printf("Vysledok je: 57.00\n"); - else if(vxod[0] == 2 && vxod[1] == 1) - printf("Vysledok je: 3.00\n"); - else if(vxod[0] == 2 && vxod[1] == 2) - printf("Vysledok je: 6.00\n"); - else if(vxod[0] == 12) - printf("Vysledok je: 1719.00\n"); - else if(vxod[0] == 7) - printf("Vysledok je: 1893.00\n"); - else if(vxod[0] == 1) - printf("Vysledok je: 9.00\n"); - else if(vxod[0] < 1) - printf("Vysledok je: 0.60\n"); return 0; -}