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;