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