Advertisement
RobertDeMilo

WB2.3 Передача параметров функций по ссылке

Sep 3rd, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. ************************************************
  9. vector <int> Sort(vector <int> v)
  10. {
  11.     sort(begin(v), end(v));
  12.     return v;
  13. }
  14. ************************************************
  15. void Sort(vector <int>& v)
  16. {
  17.     sort(begin(v), end(v));
  18. }
  19. ************************************************
  20. int main()
  21. {
  22.     vector <int> nums = { 3,6,1,2,0,2 };
  23.    
  24.     ************************************************
  25.     nums = Sort(nums);
  26.     ************************************************
  27.     Sort(nums);
  28.     ************************************************
  29.        
  30.     for (auto x : nums)
  31.     {
  32.         cout << x << " ";
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement