C语言单链表的建立.docVIP

  • 2
  • 0
  • 约 10页
  • 2018-04-06 发布于河南
  • 举报
文档全是精心选出来的精品资料,绝对值得下载!

C语言单链表的建立、输出、插入和删除的算法。 LinkList #include iostream.h #include malloc.h #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define NULL 0 typedef char ElemType; typedef struct LNode { ElemType data; LNode *next; }LNode,*LinkList; int CreateList(LinkList L) { LNode *s; char c; int flag=1; cout请输入线性表中的元素值(#结束):endl; while(flag) { cinc; if(c!=#) { s=(LNode*)malloc(sizeof(LNode)); // 为读入的字符分配存储空间 s-data=c; s-next=L-next; L-next=s; } else flag=0; } return OK; } int ShowList(LinkList L) { LinkList p; int i=0; p=L-next; cout链表逻辑结构如下:endl; while(p)

文档评论(0)

1亿VIP精品文档

相关文档