关于链表的疑惑,求解答

img


图片里的代码有没有会的呀,做了好久了,根本看不懂捏,没有学过链表,所以不清楚怎么写

供参考:

#include <stdio.h>
#include <stdlib.h>

typedef struct node {
    int    data;
    struct node* next;
}Node;

/***********Begin**************/
Node* CreatList()
{
    int n;
    Node* head = NULL, * p = NULL, * tail = NULL;
    head = (Node*)malloc(sizeof(Node));
    head->next = NULL;
    tail = head;
    scanf("%d", &n);
    while (n--) {
        p = (Node*)malloc(sizeof(Node));
        p->next = NULL;
        scanf("%d", &p->data);
        tail->next = p;
        tail = p;
    }
    return head;
}
void ShowList(Node *phead)
{
    Node* p = phead;
    if (!p || !p->next)
        return;
    else {
        while (p->next) {
            printf(p == phead ? "%d" : " %d", p->next->data);
            p = p->next;
        }
    }
}
/***********End****************/

int main(void)
{
    Node* phead;
    phead = CreatList();
    ShowList(phead);
    return 0;
}

https://blog.csdn.net/kyriekk/article/details/124124459