Advertisement
yejolga

ol_5_10

Nov 15th, 2019
161
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 <fstream>
  3. #include <vector>
  4. #include <cmath>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     ifstream cin("input.txt");
  12.  
  13.     int n;
  14.     cin>>n;
  15.  
  16.     vector <long> a;
  17.     a.resize(n);
  18.  
  19.     for(int i = 0; i < n; i++)
  20.     {
  21.         cin>>a[i];
  22.         for(int j = 0; j < i; j++)
  23.             if(a[i] == -a[j] && a[i] < a[j] || abs(a[i]) < abs(a[j]))
  24.                 swap(a[i], a[j]);
  25.     }
  26.     for(int i = 0; i < n; i++)
  27.         cout<<a[i]<<' ';
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement