diff --git a/cv3/program.c b/cv3/program.c index c5d5af2..fc8baf5 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,7 +15,6 @@ struct stack{ void print_stack(struct stack* stack); void push_stack(struct stack* stack, float value); float pop_stack(struct stack* stack); -int count_stack(struct stack* stack); @@ -40,7 +40,7 @@ int main(){ printf("\n"); continue; } - + if(char_value[0] == '+'){ float a = pop_stack(&myStack); float b = pop_stack(&myStack); @@ -74,19 +74,23 @@ int main(){ print_stack(&myStack); printf("\n"); } + } else if(isdigit(char_value[0]) != 0 ){ + float_value = strtof(char_value, NULL); + //printf("float value: %f\n",float_value); + if(float_value == 0){ + puts("bad input"); + break; + } else { + push_stack(&myStack,float_value); + print_stack(&myStack); + printf("\n"); + continue; + } } else { - float_value = strtof(char_value, NULL); - if(float_value == 0){ - puts("bad input"); - break; - } else { - push_stack(&myStack,float_value); - print_stack(&myStack); - printf("\n"); - continue; - } - } - }else { + puts("bad input"); + break; + } + } else { //push_stack(&myStack, float_value); //print_stack(&myStack); //printf("\n");