Linked list Insert

Source: Internet
Author: User
Open More ...     Pcurrent=phead; SS *c;
for (int i= 0;i< i++)
{
if (pcurrent-> a = = 3)
{
ptmp= New SS;
C=pcurrent-> Next;
Pcurrent-> next =ptmp;
pcurrent=ptmp;
Pcurrent-> next =c;
Pcurrent-> a = 20;

}
Pcurrent=pcurrent-> Next;
} Pcurrent=phead; The middle Insert list (x) a ————————— >b ————————— >⬇ ——————————— >c How to insert X. Very simple, create X, the front point X,x point to the back. Use another pointer to record the following, good point. ptmp= New Ss1; ptmp->x=18; Ptmp-> next =phead; phead=ptmp; Before inserting the list (x) ⬇ ————————— >a ————————— >b ——————————— >c How to insert X. Very simple, the creation of X,x point to the previous head, the head into X. while (pcurrent-> next)
{
P=pcurrent;
Pcurrent=pcurrent-> Next; } ptmp= new Ss1; ptmp->x=22; Pcurrent-> next =ptmp; pcurrent=ptmp;                                                                                                                                           Insert List after (x) a ————————— >b ——————————— >c ————————— >⬇ How to insert X. It's simple, create X, loop to the end of the chain, point to X.

Insert on the right here;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.