Initializacia
This commit is contained in:
parent
0c73d2017a
commit
50e07c78df
@ -25,7 +25,7 @@ void print_stack(struct stack* s) {
|
|||||||
void push_stack(struct stack* s, float value) {
|
void push_stack(struct stack* s, float value) {
|
||||||
if (s->size >= STACK_SIZE) {
|
if (s->size >= STACK_SIZE) {
|
||||||
printf("Chyba: zasobnik je plny\n");
|
printf("Chyba: zasobnik je plny\n");
|
||||||
exit(1);
|
exit(0);
|
||||||
}
|
}
|
||||||
s->values[s->size++] = value;
|
s->values[s->size++] = value;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ void push_stack(struct stack* s, float value) {
|
|||||||
float pop_stack(struct stack* s) {
|
float pop_stack(struct stack* s) {
|
||||||
if (s->size == 0) {
|
if (s->size == 0) {
|
||||||
printf("Chyba: zasobnik je prazdny\n");
|
printf("Chyba: zasobnik je prazdny\n");
|
||||||
exit(1);
|
exit(0);
|
||||||
}
|
}
|
||||||
return s->values[--s->size];
|
return s->values[--s->size];
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ int is_operator(char* input) {
|
|||||||
void perform_operation(struct stack* s, char* operator) {
|
void perform_operation(struct stack* s, char* operator) {
|
||||||
if (s->size < 2) {
|
if (s->size < 2) {
|
||||||
printf("Chyba: nedostatok operandov\n");
|
printf("Chyba: nedostatok operandov\n");
|
||||||
exit(1);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float b = pop_stack(s);
|
float b = pop_stack(s);
|
||||||
@ -62,7 +62,7 @@ void perform_operation(struct stack* s, char* operator) {
|
|||||||
} else if (strcmp(operator, "/") == 0) {
|
} else if (strcmp(operator, "/") == 0) {
|
||||||
if (b == 0) {
|
if (b == 0) {
|
||||||
printf("division by zero\n");
|
printf("division by zero\n");
|
||||||
exit(1);
|
exit(0);
|
||||||
}
|
}
|
||||||
result = a / b;
|
result = a / b;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user