Update cv3/program.c

This commit is contained in:
Marat Izmailov 2024-10-17 12:13:10 +00:00
parent c83eb68204
commit 45b15ad033

View File

@ -75,7 +75,7 @@ int main() {
}
float b = pop_stack(&mystack);
float a = pop_stack(&mystack);
float result;
float result = 0;
switch (input[0]) {
case '+':
@ -90,23 +90,27 @@ int main() {
case '/':
if (b == 0) {
printf("Error: Division by zero.\n");
break;
push_stack(&mystack, a);
push_stack(&mystack, b);
print_stack(&mystack);
continue;
}
result = a / b;
break;
default:
printf("Error: Unknown operation '%s'.\n", input);
push_stack(&mystack, a);
push_stack(&mystack, b);
break;
print_stack(&mystack);
continue;
}
if (result) {
push_stack(&mystack, result);
print_stack(&mystack);
}
}
}
return 0;
}