单向循环链表的尾插法实现
`#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
// Append the new node at the end
s->next = (*head);
(*head)=s;
}
}
sli* last = *head;
while (last->next != NULL) {
last = last->next;
}
last->next = *head;
}
// void ppeet(sli **head){
// while((head)->next!=(head)){
// printf("%d ",(*head)->next);
// head=(head)->next;
// }
// }
void ppeet(sli *head) {
sli current = head;
do {
printf("%d ", current->data);
current = current->next;
} while (current != head);
}
int main(){
sli head= NULL;
int a[]={4,5,6,4,6,4,6,3,6,3};
createsli(&head,a,10);
ppeet(head);
}`````````````````````````