include<stdio.h>
include<stdlib.h>
typedef struct slik{
int data;
struct slik* next;
}sli;
void createsli(sli** head, int a[],int size){
for(int i=0;i<size;i++){
sli* s=(sli*)malloc(sizeof(sli));
s->data=a[i];
s->next=NULL;
if (*head == NULL) {
*head = s;
} else {
// Find the last node
sli* last = *head;
while (last->next != NULL) {
last = last->next;
}
// Append the new node at the end
last->next = s;
}
}
}
void ppeet(sli **head){
while((head)!=NULL){
printf("%d ",(head)->data);
head=(head)->next;
}
}
int main(){
sli* head= NULL;
int a[]={4,5,6,4,6,4,6,3,6,3};
createsli(&head,a,10);
ppeet(&head);
}
标签:插法,head,单链,last,建立,int,next,sli,NULL From: https://www.cnblogs.com/jjjkkklll/p/18160855