`
haoningabc
  • 浏览: 1450136 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

下堆栈的helloworld

阅读更多
#include <stdlib.h>
#include <stdio.h>
typedef int Item; 
typedef struct STACKnode* link;
struct STACKnode {Item item;link next;};
static link head;
link NEW(Item item,link next)
{
        link x=malloc(sizeof *x);
        x->item=item;x->next=next;
        return x;
}
void STACKinit(int maxN){
        head=NULL;
}
int STACKempty(){
        return head==NULL;
}
STATCKpush(Item item){
        head=NEW(item,head);
}
Item STACKpop(){
        Item item=head->item;
        link t=head->next;
        free(head);
        head=t;
        return item;
}

int main(){
        printf("this is a stack\n");
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics