应该可以运行,,希望可以给和我一样正在学数据结构的同学有点帮助。。愿结交正学习C的朋友一起讨论。
#include <stdio.h>
#include <stdlib.h>
typedef struct lnode{
int data;
struct lnode *next;
}lnode,linklist;
lnode * hua_createlist ( )
{ lnode *head, *tail, *p;
int e ;
head = ( lnode *)malloc(sizeof( lnode));
tail = head;
printf("输入数据,生成“先进先出”的单链表。当输入9时,结束输入!/n");
do{
p = ( lnode *)malloc(sizeof(lnode));
scanf("%d", &e);
p -> data = e;
tail -> next = p;
tail = p;
}while(e - 9);
tail ->next = NULL;
return head;
}
void hua_output( linklist *L )
{
lnode *p;
p = L ->next;
printf("表中节点为:");
while( p != 0){
printf("/t%d", p -> data);
p = p -> next;
}
}