The second edition of Zhejiang University data structure Exercise 3.5 The inverse of the list m element the answer is a bit wrong.

Source: Internet
Author: User

ElementType Find (list L, int m)  {      list p1 = L;     List P2 = L;      List pLast = NULL;      int c = 0;      while (p1) {          if (c = = m) {              P2 = L;          }          P1 = p1->next;          P2 = p2->next;          PLast = p2;          C + +;      }      if (C > m)        return plast->data;  
else return-1;}

  

ElementType Find (list L, int m)  {      list pcurrent = L;     List pfind = L;          for (int i =0; i<m;i++)        if (pcurrent)            pcurrent = pcurrent->next;        else            return-1;     while (pcurrent) {        Pfind = pfind->next;        Pcurrent = pcurrent->next;    }    return pfind->data;}

  

The second edition of Zhejiang University data structure Exercise 3.5 The inverse of the list m element the answer is a bit wrong.

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.