标签:
c语言实现
#include <stdio.h>
#include <malloc.h>
typedef struct node{
int data;
struct node*next;
}
ElemSN;
ElemSN*createLink (int*a,int n) {
int i;
ElemSN*h,*t;
h=t=(ElemSN*)malloc(sizeof(ElemSN));
t->next=NULL;
for(i=0;i<n;i++) {
t=t->next=(ElemSN*)malloc(sizeof(ElemSN));
t->data=a[i];
t->next=NULL;
}
return h;
}
int main(void) {
int a[5]={10,20,30,40,50};
ElemSN*h,*p;
h= createLink (a,5);
for(p=h;p->next;p=p->next)
printf("%d,",p->next->data);
return 0;
}
标签:
原文地址:http://www.cnblogs.com/JaneSJ/p/5450479.html