关于数据结构的问题(2)
#include <stdio.h>#include <stdlib.h>
typedef struct stacknode
{int data;
struct stacknode *next;
}stacknode,* linkstack;
linkstack top;
void push(linkstack top,int x)
{stacknode *p=new stacknode;
p->data=x;
p->next=top;
top=p;
}
int pop(linkstack top)
{int x;
stacknode *p=top;
x=p->data;
top=p->next;
free (p);
return x;
}
void showstack(linkstack top)
{stacknode *p=top;
if(p==NULL)
printf("it is kong");
else
{printf("it is:");
while(p!=NULL)
{printf("%6d",p->data);
p=p->next;
}
printf("\n");
}}
main()
{linkstack top=NULL;
push(top,1);
push(top,2);
printf("%5d",pop(top));
请顺便看看这个吧!!!!!!!!!!!!!!也运行不了啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!为什么????????????????????????????????????