线性链表

来源:百度知道 编辑:UC知道 时间:2024/06/21 20:10:34
线性链表 与线性结构有关系吗

有的
线性结构是一种有且只有一个前驱和有且只有一个后继的数据结构
线性链表是一种线性结构
还有顺序表也是一种线性结构

链表的物理内存地址不相连 而顺序表的地址是相连的

线性链表。。貌似隶属于线性结构。。。

#include<stdio.h>
#define EXIT -1

typedef struct list{
int num;
struct list *next;
}LIST;

LIST *scan_list(void)
{
int data;
LIST *headp,*newp,*tempp;

scanf("%d",&data);
if(data == EXIT)
headp = NULL;
else
{
headp = (LIST *)malloc(sizeof(LIST));
headp->num = data;
tempp = headp;
}

for(scanf("%d",&data);data != EXIT;scanf("%d",&data))
{
newp = (LIST *)malloc(sizeof(LIST));
newp->num = data;
tempp->next = newp;
tempp = newp;
}

tempp->next = NULL;

return headp;
}<