Advertisement
Bibodui

ЯМП кп списки №1

Dec 9th, 2020 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. Node* SearchMax()
  2. {
  3.     Node* tmp = head->Next;
  4.     Node* address = head;
  5.     int max = head->Value;
  6.     while (tmp != nullptr)
  7.     {
  8.         if (max < tmp->Value)
  9.         {
  10.             max = tmp->Value;
  11.             address = tmp;
  12.         }
  13.         tmp = tmp->Next;
  14.     }
  15.  
  16.     max = head->Value;
  17.     head->Value = address->Value;
  18.     address->Value = max;
  19.  
  20.     return nullptr;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement