#include
#include
typedef struct ListNode{
struct ListNode *next;
int data ;
}Node,*Pnode;
void init(Pnode Phead){
Phead = (Pnode)malloc(sizeof(Node));
Phead->next=NULL;
}
void rearinsert(Pnode Phead,int n,int a[]){
Pnode Prear,Pnew;
Prear=Phead;
for(int i=0;i
Pnew = (Pnode)malloc(sizeof(Node));
Pnew->data= a[i];
Pnew->next=NULL;
Prear->next=Pnew;
Prear=Pnew;
}
}
void head_insert(Pnode Phead,int n,int a[]){
Pnode Pnew;
for(int i=0;i
Pnew=(Pnode)malloc(sizeof(Node));
Pnew->data= a[i];
Pnew->next=Phead->next;
Phead->next=Pnew;
}
}
void display(Pnode list){
Pnode p=list->next;
while(p!=NULL){
printf("%d",p->data);
printf(" ");
p=p->next;
}
}
void destory(Pnode list){
Pnode p,pre;
p=pre=list;
while(pre!=NULL){
pre=p->next;
free(p);
p=pre;
}
free(pre);
}
int select(Pnode list ,int n){// 提取i号元素的数据
n=n-1;
Pnode p=list->next;
for(int i=0;i<=n;++i){
p=p->next;
}
return p->data;
}
void main(){
Pnode list;
int a[]={3,5,6,9};
int n=4;
init(list);
rearinsert(list,4,a);
display(list);
}