算法:C语言实现 (4)下推栈的数组实现

这里就附了一个实现文件

#include <stdlib.h>
#include "item.h"

static Item *s;
static int N;

void STACKinit(int maxN)
{
    s = (Item*)malloc(maxN*sizeof(Item));
    N = 0;
}

int STACKempty()
{
    return N == 0;
}

void STACKpush(Item item)
{
    s[N++] = item;
}

Item STACKpop()
{
    return s[--N];
}

 

posted @ 2013-11-18 23:41  CJin  阅读(556)  评论(0编辑  收藏  举报