Răspuns :
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int k=0, n, j, aux;
string line, numere;
ifstream fileIn("pr10.in");
if (fileIn.is_open())
{
while ( getline (fileIn, line) )
{
if(k!=1){
n=stoi(line);
k++;
} else {
numere=line;
}
}
}
int sirNr[n];
istringstream ss(numere);
int i=0;
do {
string number;
ss>>number;
if(number!="" && number!=" "){
sirNr[i]=stoi(number);
i++;
}
} while (ss);
fileIn.close();
k=0;
for(i=0; i<n; i++){
if(sirNr[i]%2==0){
aux=sirNr[i];
sirNr[i]=sirNr[k];
sirNr[k]=aux;
k++;
}
}
for(i=0; i<n; i++){
for(j=0; j<n; j++){
if(sirNr[i]%2==0 && sirNr[j]%2==0 && sirNr[i]<sirNr[j]){
aux=sirNr[i];
sirNr[i]=sirNr[j];
sirNr[j]=aux;
}
if(sirNr[i]%2!=0 && sirNr[j]%2!=0 && sirNr[i]>sirNr[j]){
aux=sirNr[i];
sirNr[i]=sirNr[j];
sirNr[j]=aux;
}
}
}
for(i=0; i<n; i++){
cout<<sirNr[i]<<" ";
}
return 0;
}