#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;

class mas
{
int n;
int *ar;
public:
mas(int);
~mas();
void vivod();
void sort();
};

void main()
{
	int m;
	cout << "vvedite razmer massiva"<< endl;
	cin >> m;
	mas obj(m);
	cout << "ishodni massiv"<< endl;
	obj.vivod();
	obj.sort();
	cout << "polucheni massiv"<< endl;
	obj.vivod();
}


mas::mas(int k)
{
	n=k;
	ar = new int[n];
	srand(time(NULL));
	for (int i=0; i<n; i++)
		ar[i]=rand()%3;
}

void mas::vivod()
{
	for (int i=0; i<n; i++)
		cout << ar[i]<< " ";
}
void mas::sort()
{
	int t=0, p=0,q,z=0;
	for (int i=0; i<n; i++)
	{
		if (ar[i]==t) 
		{
			q=ar[p];
			ar[p]=ar[i];
			ar[i]=q;
			p++;
		}

	}
	t=2;
	for (int i=p+1; i<n; i++)
	{
		if (ar[i]==t) 
		{
			q=ar[p];
			ar[p]=ar[i];
			ar[i]=q;
			p++;
		}

	}
}
mas::~mas()
{
	delete[] ar;
	cout <<"dsfsdr";
}