Răspuns :
Răspuns:
#include <iostream>
#include <fstream>
using namespace std;
int cifra(char c){
int aux = c - '0';
if(aux >=0 && aux <=9){
return 1;
}
return 0;
}
int numar(int n, int cif){
return n*10+cif;
}
int frecventa[10];
int main()
{
ifstream in("atestat.in");
ofstream out("atestat.out");
char c;
bool test = false;
while(in>>c){
if(cifra(c) == 1){
test = true;
frecventa[c-'0'] = 1;
}
}
if(test == false){
out<<"Nu exista\n";
out.close();
in.close();
return 0;
}
long int nr = 0;
for(int i = 1 ; i<10;i+=2){
if(frecventa[i] == 1){
nr = numar(nr,i);
}
}
for(int i = 8 ; i>=0;i-=2){
if(frecventa[i] == 1){
nr = numar(nr,i);
}
}
out<<nr;
out.close();
in.close();
return 0;
}
Explicație: