diff --git a/cv3/program.c b/cv3/program.c index 7b9a5ac..30ad455 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -2,7 +2,7 @@ #include #include #include - /////////////@@@@@@@@@@@@@@ +///@ #define STACK_SIZE 500 struct Stack @@ -31,7 +31,7 @@ float pop_stack(struct Stack* stack) } int count_stack(struct Stack* stack) { - + return stack->size; } void print_stack(struct Stack* stack) @@ -62,6 +62,12 @@ int main() float op1, op2, rez; if(c=='+'||c=='-'||c=='/'||c=='*') { + if(count_stack(&mystack)<2) + { + printf("not enough operands\n"); + err=3; + break; + } op2=pop_stack(&mystack); op1=pop_stack(&mystack); switch(c) @@ -97,9 +103,8 @@ int main() print_stack(&mystack); } } - else { - break; - } + else break; + }while(1); if(!err) printf("no input\n"); @@ -108,4 +113,3 @@ int main() -