Advertisement
Neveles

Untitled

Feb 13th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. List operator&(const List& firstList, const List& secondList)
  2. {
  3.     List resultList;
  4.     List::Node* firstPtr = firstList.head_;
  5.     List::Node* secondPtr = secondList.head_;
  6.     while (firstPtr != nullptr)
  7.     {
  8.         while (secondPtr != nullptr)
  9.         {
  10.             if (firstPtr->value_ == secondPtr->value_)
  11.             {
  12.                 resultList += firstPtr->value_;
  13.                 break;
  14.             }
  15.             secondPtr = secondPtr->next_;
  16.         }
  17.         firstPtr = firstPtr->next_;
  18.         secondPtr = secondList.head_;
  19.     }
  20.     return resultList;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement