Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
463 B
4
Indexable
Never
void ThemNode_p_SauNode_q(LIST &l, NODE *p)
{
  int x;
  cout << "\nNhap gia tri node q: ";
  cin >> x;
  NODE *q = KhoiTaoNODE(x);
  if (q->data == l.pHead->data && l.pHead->pNext == NULL)
  {
    ThemVaoCuoi(l, p);
  }
  else
  {
    for (NODE *k = l.pHead; k != NULL; k = k->pNext)
    {
      if (q->data == k->data)
      {
        NODE *h = KhoiTaoNODE(p->data);
        h->pNext = k->pNext;
        k->pNext = h;
      }
    }
  }
}