不带头结点,需要创建n个结点,包括三个指针,头指针head,一个游标指针p和创建结点的s....

void creat(List &L,int n)
{
    int e;
    List s,p;
    L=NULL;
    for(int i=1;i<=n;i++)/*n个结点*/
    {
        s=(List)malloc(sizeof(Node));
        cin>>e;
        s->data=e;
        
        if(L==NULL)
        L=s;
        else
        p->next=s;
        p=s;
    }
    p->next=L;
}

 

 



 

 

相关文章:

  • 2022-12-23
  • 2021-11-14
  • 2021-05-25
  • 2021-11-07
  • 2021-11-15
  • 2021-09-22
  • 2021-12-31
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案