#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
int data;
struct Node* next;
}Node;
Node* creat(int Array[]){
Node *p,*pre,*head;
head=(Node*)malloc(sizeof(Node));
head->next=NULL;
pre=head;
for(int i=0;i<5;i++){
p=(Node*)malloc(sizeof(Node));
p->data=Array[i];
p->next=head->next;
head->next=p;
}
return pre;//头插法(相当于逆序
}
int main(){
int Array[5]={5,3,6,1,2};
Node* L=creat(Array);
L=L->next;
while(L!=NULL){
printf("%d ",L->data);
L=L->next;
}
return 0;
}
03-25
5584
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)