yejolga

ol2_2

Jan 28th, 2020
52
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 <vector>
  3. #include <algorithm>
  4.  
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     cin>>n;
  13.     vector<long> v1;
  14.     v1.resize(n);
  15.     for(int i = 0; i < n; i++)
  16.         cin>>v1[i];
  17.     sort(v1.begin(), v1.end());
  18.     long a = 0, b = n-1;
  19.     for(int i = 0; i < n/2 + n%2; i++)
  20.     {
  21.         if(a < n/2)
  22.             cout<<v1[a]<<' ';
  23.         a++;
  24.         if(b >= n/2)
  25.             cout<<v1[b]<<' ';
  26.         b--;
  27.     }
  28.  
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment