Create a single list and forward runs after the interpolation method

1, after the interpolation to create a single list

 

void CreateList(List &L,int n)
{
    L=new LNode;
    L->next=NULL;
    r=L;
    for(i=0;i<n;++i)
   {
      p=new LNode;
      cin>>p->data;
      p->next=NULL;
      r->next=p;
      r=p;
   }
}

2, create a single list forward runs law

void CreatList(List &L,int n)
{
    L=new LNode;
    L->next=NULL;
    for(int i=0;i<n;i++)
   {
      p=new LNode;
      cin>>p->data;
      p->next=L->next;
      L->next=p;  
   } 
}

Guess you like

Origin www.cnblogs.com/h694879357/p/11487470.html