30 lines
480 B
C
30 lines
480 B
C
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define STACK_SIZE 10
|
|
|
|
struct stack {
|
|
float values[STACK_SIZE];
|
|
int size;
|
|
};
|
|
|
|
void push_stack(float value, struck stack *s){
|
|
if (s->size >=STACK_SIZE){
|
|
printf("Zapsinik je plny\n")
|
|
exit (1);
|
|
}
|
|
s->values[s->size] = value;
|
|
s->size++;
|
|
}
|
|
|
|
float pop_stack(struct stack *s) {
|
|
if (s->size <= 0){
|
|
printf("zasobnik je prazdny \n");
|
|
exit(1);
|
|
}
|
|
s->size--;
|
|
return s->values[s->size];
|
|
}
|
|
|