Răspuns :
#include<bits/stdc++.h>
using namespace std;
ifstream fin("cifra2.in");
ofstream out("cifra2.out");
int cifmin(int x)
{
int cif,cifm=INT_MAX;
while(x)
{
cif=x%10;
if(cif<cifm)
cifm=cif;
x/=10;
}
return cifm;
}
int elimuc(int x,int q)
{
int nou=0,p=1;
while(x!=0)
{
if(x%10!=q)
{
nou=nou+(x%10-q)*p;
p=p*10;
}
x=x/10;
}
return nou;
}
int main()
{
int x,q,k,l;
fin>>x;
int xx=x;
q=cifmin(x);
out<<cifmin(x)<<endl;
out<<elimuc(x,q)<<endl;
while(xx>9)
{
k=cifmin(xx);
l=elimuc(xx,k);
xx=l;
}
out<<l<<endl;
return 0;
}