From 26330e18e853cf2e040a78cdf57c202a91deb5c8 Mon Sep 17 00:00:00 2001 From: Deinerovych Date: Wed, 16 Oct 2024 10:18:57 +0200 Subject: [PATCH] 6 --- cv3/program.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 7b78371..8d6da9c 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -81,12 +81,10 @@ int main() { else if (is_operation(arr)) { if (stack_top < 1) { if (!first_output) { - printf(" "); + printf("\n"); } - printf("no input"); - first_output = false; - operation_successful = false; - continue; + printf("no input\n"); + return 0; // Завершение программы при ошибке } float n2 = pop(); @@ -97,34 +95,24 @@ int main() { if (!first_output) { printf(" "); } - printf("%.2f", result); - first_output = false; - operation_successful = true; + printf("%.2f\n", result); + first_output = true; // Ожидаем новый ввод на новой строке } else { if (!first_output) { - printf(" "); + printf("\n"); } - printf("no input"); - first_output = false; - operation_successful = false; - continue; + printf("no input\n"); + return 0; // Завершение программы при ошибке } } - if (operation_successful && stack_top == 0) { - if (!first_output) { - printf(" "); - } - printf("%.2f", pop()); - } else if (!operation_successful) { - if (!first_output) { - printf(" "); - } - printf("no input"); + if (stack_top == 0) { + printf("%.2f\n", pop()); + } else { + printf("no input\n"); } - printf("\n"); return 0; }