Răspuns:
#include<iostream>
#include<vector>
using namespace std;
int main() {
int n,v,aux,j=0;
vector<int> x;
cin >> n;
if (n > 99)
return -1;
while (n != 0) {
cin >> v;
x.push_back(v);
n--;
}
for (int i = 0; i < x.size(); i++)
{
if (x[i] % 10 == 3)
{
aux = x[j];
x[j] = x[i];
x[i] = aux;
j++;
}
}
for(int i=0;i<j-1;i++)
for (int m = i + 1; m < j; m++)
{
if (x[i] > x[m])
{
aux = x[i];
x[i] = x[m];
x[m] = aux;
}
}
for (int i = j; i < x.size()-1; i++)
for (int m = i + 1; m < x.size(); m++)
{
if (x[i] < x[m])
{
aux = x[i];
x[i] = x[m];
x[m] = aux;
}
}
for (int i = 0; i < x.size(); i++)
cout << x[i] << " ";
}