From 08f0f63542bd73915798a159666d0788052b4b32 Mon Sep 17 00:00:00 2001 From: Deinerovych Date: Wed, 16 Oct 2024 12:03:17 +0200 Subject: [PATCH] 21 --- cv3/program.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index b36eec8..b4ded8d 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -33,7 +33,7 @@ float calculator(float n1, float n2, char operation) { return n1 / n2; } else { printf("division by zero\n"); - exit(1); + return n1; } } return 0; @@ -63,11 +63,9 @@ void print_stack() { } printf("%.2f", stack[i]); } - printf(" \n"); // добавляем пробел перед новой строкой + printf(" \n"); } - - int main() { char arr[50]; char *pend; @@ -93,13 +91,15 @@ int main() { float n1 = pop(); char operation = arr[0]; float result = calculator(n1, n2, operation); - push(result); + if (!(operation == '/' && n2 == 0)) { + push(result); + } print_stack(); } } if (stack_top == 0) { - pop(); + pop(); printf("no input\n"); } else { printf("no input\n");