# include
# include
//定义结构体
typedef struct node{
int data; //数据域
struct node * next; //指针域
}ElemSN; //将 struct node重命名为 ElemSN
//建链表
ElemSN * CreateLink(int a[],int n)
{
ElemSN *h,*p,*t; //h为头指针
h=NULL; //头指针指向NULL
for(int i=0;idata = a[i]; //访问数据
p->next = NULL; //访问后继
if(!h)
h=t=p;
else
t=t->next=p;
}
return h;
}
//输出链表
void PrintLink(ElemSN *h)
{
ElemSN *p;
for(p=h;p;p=p->next)
printf("%5d",p->data);
printf("\n");
}
int main(void)
{
int n; //n为所需结点数
scanf("%d",&n);
int a[n];
for(int i=0;i
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)