请问这个应该怎么做?第一张是原题,第二张是机翻,下面第一个是stack.c,第二个是stack.h。请大lao帮我编程一下,蟹蟹。
#include <stdlib.h>
#include <stdio.h>
#include "Stack.h"
struct stack {
int items[MAX_SIZE];
int size;
};
Stack *stackCreate(void) {
Stack *s = malloc(sizeof (struct stack));
if(s == NULL) {
fprintf(stderr,"Insufficient Memory\n");
exit(EXIT_FAILURE);
}
s->size = 0;
return s;
}
void stackPush(Stack *s, int item) {
int index = s->size;
if(s->size < MAX_SIZE) {
s->items[index] = item;
s->size++;
} else {
fprintf(stderr,"Stack full\n");
stackDestroy(s);
exit(EXIT_FAILURE);
}
}
#define MAX_SIZE 100
typedef struct stack Stack;
Stack *stackCreate(void);
void stackPush(Stack *s, int item);
int stackTop(Stack *s);
int stackPop(Stack *s);
int stackSize(Stack *s);
void stackDestroy(Stack *s);