新手上路,请问这个逆置函数哪里写错了?

#include<iostream>

using namespace std;

typedef struct LNode
{
    int data;
    struct LNode *next;
}LNode;

void LinkList(LNode *&head)
{
    
    head=(LNode*)malloc(sizeof(LNode));
    (head)->next=NULL;
    LNode *p=NULL,*r=head;
    int n;
    cout<<"请输入元素个数:";
    cin>>n;
    for(int i=0;i<n;++i)
    {
        p=(LNode*)malloc(sizeof(LNode));
        p->next=NULL;
        cout<<"请输入第"<<i+1<<"个元素:";
        cin>>p->data;
        p->next=r->next;
        r->next=p;
        r=p;
    }
}

void reverse(LNode *L)
{
    LNode *s=L->next;
    while(s->next!=NULL);
    s=s->next;
    LNode *t=L->next;
    while(t!=s)
    {
        L->next=t->next;
        t->next=NULL;
        s->next=t;
        t=L->next;
    }  
    
}


int main()
{
    LNode *HEAD=NULL;
    LinkList(HEAD);
    reverse(HEAD);
    LNode *q;
    q=HEAD->next;
    while(q)
    {
        cout<<q->data<<" ";
        q=q->next;
    }
    return 0;
}

 

第35行末尾多了个分号

C和C++完整教程:https://blog.csdn.net/it_xiangqiang/category_10581430.html