Advertisement
RobertDeMilo

WB3.3

Sep 4th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iomanip>
  6.  
  7. using namespace std;
  8.  
  9. void Print(const vector <int>& v, const string& title)
  10. {
  11.     cout << title << ": ";
  12.     for (const auto& i : v)
  13.     {
  14.         cout << i << ' ';
  15.     }
  16. }
  17.  
  18. int main()
  19. {
  20.     vector<int> v = { 1,3,5,2,4 };
  21.     Print(v, "init");
  22.  
  23.     /*for (int i = 0; i < v.size(); ++i)
  24.     {
  25.         ++v[i];
  26.     }*/
  27.  
  28.     for (auto& i : v)
  29.     {
  30.         ++i;
  31.     }
  32.  
  33.     cout << endl;
  34.     Print(v, "inc");
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement