#include <iostream>
#include <algorithm>
#include <list>
#include <time.h>

using namespace std;

int main()
{
    const int n=21;
    int m[n];
    srand(time(0));
    cout<<"Massiv M:\n";
    for(int i=0;i<n;i++)
    {
        m[i]=rand() % 1000;	//диапазон для наглядности
        cout<<"m["<<i<<"]= "<<m[i]<<endl;
    }
	
	/////////////////////////////////////////////////////
	list<int> tmpN;	//создаём список для сортировки
	
	copy_if(begin(m), end(m), back_inserter(tmpN), [](const int x){ return x%2; });	//нечётные числа
	
	tmpN.sort([](const int a, const int b){ return a > b; });	//по убыванию
		
	cout << "Нечётные числа (" << tmpN.size() << " - элементов): ";
	
	for(int i : tmpN)	//вывод
		cout << i << ' ';
	
	tmpN.clear();	//очистка списка
	
	copy_if(begin(m), end(m), back_inserter(tmpN), [](const int x){ return (x+1)%2; });	//чётные числа
	
	tmpN.sort([](const int a, const int b){ return a < b; });	//по возрастанию
	
	cout << "\nЧётные числа(" << tmpN.size() << " - элементов): ";
	
	for(int i : tmpN)	//вывод
		cout << i << ' ';
	
	//////////////////////////////////////////////////////////
    return 0;
}