Update du3/program.c

This commit is contained in:
Denis Landa 2025-10-16 17:21:07 +00:00
parent 7a0bb2c020
commit 953e42ee1b

View File

@ -18,7 +18,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("no input\n"); printf("full stack\n");
exit(0); exit(0);
} }
s->values[s->size] = value; s->values[s->size] = value;
@ -27,7 +27,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("no input\n"); printf("not enough operands\n");
exit(0); exit(0);
} }
s->size--; s->size--;
@ -45,7 +45,7 @@ int main() {
strcmp(input, "*") == 0 || strcmp(input, "/") == 0) { strcmp(input, "*") == 0 || strcmp(input, "/") == 0) {
if (s.size < 2) { if (s.size < 2) {
printf("no input\n"); printf("not anough operands\n");
exit(0); exit(0);
} }
@ -65,7 +65,7 @@ int main() {
char *endptr; char *endptr;
float val = strtof(input, &endptr); float val = strtof(input, &endptr);
if (*endptr != '\0') { if (*endptr != '\0') {
printf("no input\n"); printf("division by zero\n");
exit(0); exit(0);
} }
push_stack(&s, val); push_stack(&s, val);