Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main()
- {
- ifstream cin("input.txt");
- int n;
- cin>>n;
- vector <long> a;
- a.resize(n);
- for(int i = 0; i < n; i++)
- {
- cin>>a[i];
- for(int j = 0; j < i; j++)
- if(a[i] == -a[j] && a[i] < a[j] || abs(a[i]) < abs(a[j]))
- swap(a[i], a[j]);
- }
- for(int i = 0; i < n; i++)
- cout<<a[i]<<' ';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement