upd again cv3
This commit is contained in:
parent
4a2c5d12a7
commit
6324b6bf2f
@ -29,6 +29,10 @@ float getnpop(struct stack* stack)
|
|||||||
|
|
||||||
int calculate(struct stack* stack, char operator)
|
int calculate(struct stack* stack, char operator)
|
||||||
{
|
{
|
||||||
|
if(stack->size < 2)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
float num1 = getnpop(stack);
|
float num1 = getnpop(stack);
|
||||||
float num2 = getnpop(stack);
|
float num2 = getnpop(stack);
|
||||||
float res = 0;
|
float res = 0;
|
||||||
@ -108,6 +112,11 @@ int main(int argc, char const *argv[])
|
|||||||
printf("division by zero\n");
|
printf("division by zero\n");
|
||||||
return 0;
|
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++)
|
for (int i = 0; i < calc_stack.size; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user