#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
int main()
{
srand(time(NULL));
const int n = 20;
std::vector<int> arr(n);
for(int i = 0;i < n;i++)
arr[i] = -20 + rand() % 40;
}
for(const int i : arr)
std::cout << i << " ";
std::cout << std::endl;
std::sort(arr.begin(),arr.end(),[](int a,int b){ return abs(a) > abs(b); });
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
int main()
{
srand(time(NULL));
const int n = 20;
std::vector<int> arr(n);
for(int i = 0;i < n;i++)
{
arr[i] = -20 + rand() % 40;
}
for(const int i : arr)
{
std::cout << i << " ";
}
std::cout << std::endl;
std::sort(arr.begin(),arr.end(),[](int a,int b){ return abs(a) > abs(b); });
for(const int i : arr)
{
std::cout << i << " ";
}
}