From 538a1d1a4d7a1c149e1f636378ccba3453c8a45b Mon Sep 17 00:00:00 2001 From: Deinerovych Date: Wed, 16 Oct 2024 10:22:46 +0200 Subject: [PATCH] 7 --- cv3/program.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 8d6da9c..3f5b69e 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -61,7 +61,6 @@ int main() { char *pend; stack_top = -1; bool first_output = true; - bool operation_successful = true; while (fgets(arr, 50, stdin)) { if (arr[0] == '\n' || arr[0] == EOF) { @@ -76,7 +75,6 @@ int main() { } printf("%.2f", number); first_output = false; - operation_successful = true; } else if (is_operation(arr)) { if (stack_top < 1) { @@ -84,7 +82,7 @@ int main() { printf("\n"); } printf("no input\n"); - return 0; // Завершение программы при ошибке + return 0; } float n2 = pop(); @@ -95,22 +93,18 @@ int main() { if (!first_output) { printf(" "); } - printf("%.2f\n", result); - first_output = true; // Ожидаем новый ввод на новой строке - } - else { - if (!first_output) { - printf("\n"); - } - printf("no input\n"); - return 0; // Завершение программы при ошибке + printf("%.2f", result); + first_output = false; } } if (stack_top == 0) { - printf("%.2f\n", pop()); + if (!first_output) { + printf(" "); + } + printf("\n%.2f\n", pop()); } else { - printf("no input\n"); + printf("\nno input\n"); } return 0;