#include<stdio.h>
#include<stdlib.h>
#define datatype int
typedef struct ListNodeptrL;
struct ListNode{
datatype dada;
struct ListNodenext;
};
ptrL creatList(ptrL head, int a[], int len){
int i;
ptrL newNode;
head=(ptrL)malloc(sizeof(struct ListNode));
head->next=NULL;
for(i=len-1;i<=0;i--){
newNode=(ptrL)malloc(sizeof(struct ListNode));
newNode->dada=a[i];
newNode->next=head->next;
head->next=newNode;
}
return head;
}
void printList(ptrL head){
head=head->next;
while(head!=NULL){
head=head->next;
printf("%d ",head->dada);
head=head->next ;
}
printf("--------\n");
}
int main(){
int a[]={1,5,4,2,6,8,9};
int len=sizeof(a)/sizeof(int);
ptrL newList= creatList( newList, a, len);
printList(newList);
return 0;
}