ifndef STACK_H
define STACK_H
define stack_size 10
include”stdio.h”
struct ListNode {
int date[stack_size];
int top;
};
typedef struct ListNode node;
void init(node *s);
void pop(node *s,void *e);
void push(node *s, void *e);
int empty(node s);
int size(node s);
endif
include”stdio.h”
include”Stack.h”
include”stdlib.h”
include “string.h”
void init(node *s){
s->top = -1;
memset(s->date, 0, sizeof(s->date));
}
void pop(node *s, void *e){
if (s->top == -1){
return;
}
e = &s->date[s->top];
s->top–;
}
void push(node *s,void *e){
if (s->top == stack_size)
return;
s->top++;
e = &s->date[s->top];
}
int empty(node s){
if (s.top == -1)
return 1;
return 0;
}
int size(node s){
if (s.top == -1){
return 0;
}
return s.top + 1;
}
include”stdio.h”
include”Stack.h”
typedef struct Node{
int date;
int mouth;
}year;
int main(void){
year y[10];
node n;
init(&n);
for (int i = 0; i < 10; i++){
y[i].date = i;
y[i].mouth = i + 30;
push(&n, (void*)&y[i]);
}
}