Update cv3/program.c

This commit is contained in:
Viktor Daniv 2024-10-07 12:37:02 +00:00
parent 5b84218b3f
commit 3e533069b0

View File

@ -48,7 +48,7 @@ int perform_operation(Calculator *calc, char op) {
if (!pop(calc, &b) || !pop(calc, &a)) { if (!pop(calc, &b) || !pop(calc, &a)) {
return 0; // Не вдалося вилучити два числа return 0; // Не вдалося вилучити два числа
} }
int bub = 0;
switch (op) { switch (op) {
case '+': case '+':
push(calc, a + b); push(calc, a + b);
@ -62,9 +62,8 @@ int perform_operation(Calculator *calc, char op) {
case '/': case '/':
if (b == 0) { if (b == 0) {
printf("division by zero\n"); printf("division by zero\n");
bub = 1;
break; break;
} else {
printf("no input\n");
} }
push(calc, a / b); push(calc, a / b);
@ -75,7 +74,9 @@ int perform_operation(Calculator *calc, char op) {
} }
print_stack(calc); print_stack(calc);
if(bub == 0) {
printf("no input\n");
}
return 1; return 1;
} }