Advertisement
Felanpro

Usage of initlializer_list<>. (in function)

Nov 2nd, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <initializer_list>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int max(initializer_list<int> xyz)
  8. {
  9.     vector<int> a = xyz;
  10.  
  11.     int const_size = xyz.size();
  12.  
  13.     int _iterator = 0;
  14.  
  15.     while(_iterator < const_size - 1)
  16.     {
  17.         if(a.at(_iterator) > a.at(_iterator + 1))
  18.         {
  19.             return a.at(_iterator);
  20.         }
  21.         else
  22.             return a.at(_iterator + 1);
  23.     }
  24. }
  25.  
  26. int main()
  27. {
  28.     cout << max({10, 20});
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement