From a4f88b62de5f4d353a5542f6e883161391ec4190 Mon Sep 17 00:00:00 2001 From: an154gf Date: Mon, 10 Mar 2025 14:40:06 +0100 Subject: [PATCH] fix s nespravnymi operatormi 4 --- du3/program.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/du3/program.c b/du3/program.c index e0a269e..d23454d 100644 --- a/du3/program.c +++ b/du3/program.c @@ -18,6 +18,7 @@ int main() { int index = 0; while (fgets(buffer, sizeof(buffer), stdin) != NULL) { int error = 0; + int operator_count = 0; if (buffer[0] == '\n') break; index = 0; eq_index = 0; @@ -47,6 +48,7 @@ int main() { equation[eq_index][0] = buffer[index]; equation[eq_index][1] = '\0'; eq_index++; + operator_count++; } index++; } @@ -54,6 +56,12 @@ int main() { equation[eq_index][eq_operand_length] = '\0'; eq_index++; } + if (operator_count < 2) { + error = 1; + strcpy(output[output_length], "CHYBA"); + output_length++; + + } float total = 0.0; char last_operator = '+'; int sign = 0;