#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");
}
下堆栈的helloworld
最新推荐文章于 2024-08-30 16:39:46 发布