upd again cv3

This commit is contained in:
Ivan Leichenko 2024-10-14 15:47:58 +02:00
parent 4a2c5d12a7
commit 6324b6bf2f

View File

@ -29,6 +29,10 @@ float getnpop(struct stack* stack)
int calculate(struct stack* stack, char operator)
{
if(stack->size < 2)
{
return 2;
}
float num1 = getnpop(stack);
float num2 = getnpop(stack);
float res = 0;
@ -108,6 +112,11 @@ int main(int argc, char const *argv[])
printf("division by zero\n");
return 0;
}
else if(calculate(&calc_stack, buf[0]) == 2)
{
printf("not enough operands\n");
return 0;
}
}
for (int i = 0; i < calc_stack.size; i++)
{