diff --git a/cv3/program.c b/cv3/program.c index 578b096..9b33161 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,7 +1,7 @@ #include #include #include - +////@@@@ #define STACK_SIZE 500 struct Stack @@ -17,13 +17,13 @@ int count_stack(struct Stack* stack); void push_stack(struct Stack* stack, float value) { - assert(stack->size < STACK_SIZE); + assert(stack->size < STACK_SIZE); // Program spadne, ak zapisuje mimo stack->values[stack->size] = value; stack->size += 1; } float pop_stack(struct Stack* stack) { - assert(stack->size > 0); + assert(stack->size > 0); // Program spadne, ak číta mimo float value = stack->values[stack->size-1]; stack->size -= 1; return value; @@ -37,8 +37,9 @@ void print_stack(struct Stack* stack) { for (int i=0; isize; i++) { - printf("%f/", stack->values[i]); + printf("%.2f ", stack->values[i]); } + printf("\n"); } @@ -54,9 +55,10 @@ int main() do { char* p=fgets(buf, 299, stdin); - + //printf("{%s}",buf); if(!p) - { + { + //printf("=="); break; } else @@ -73,13 +75,15 @@ int main() case '-': rez=op1-op2; break; case '/': rez=op1/op2; break; case '*': rez=op1*op2; break; - } - push_stack(&mystack, rez); - printf(" %.2f\n", rez); - + } //p } else - push_stack(&mystack, atof(buf)); + { + rez=atof(buf); + } + push_stack(&mystack, rez); + //printf(" %.2f\n", rez); + print_stack(&mystack); } }while(1);