From 7ae3daf85e3c7e8b072f7d4faf7c03f99e648af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Korpesio?= Date: Wed, 20 Oct 2021 10:53:38 +0200 Subject: [PATCH] prvy --- cv3/program.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 499e767..a0556f3 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -17,7 +17,7 @@ int main() { int i; int input = 0; float p; - //float prvy, druhy, vys; + float vys; while (fgets(line, LINESIZE, stdin)) { velkost = strlen(line); if (velkost == 1 && line[velkost - 1] == '\n') { @@ -45,6 +45,8 @@ int main() { if (line[0] == '/') { if (number[a - 1].cislo == 0){ printf("division by zero"); + vys = 1; + a = 0; } else { number[a - 2].cislo = number[a - 2].cislo / number[a - 1].cislo; @@ -62,9 +64,9 @@ int main() { for (i = 0; i < a; i++){ printf("%.2f ", number[i].cislo); } - - printf("\n"); - + if (vys != 1) { + printf("\n"); + } } printf("no input\n"); return 0;