Răspuns :
#include<iostream>
using namespace std;
int n,k,nr1,val=0,t;
int main()
{cin>>n>>k;
while(n>0)
{t=n%10;
if(t<=k) nr1=nr1*10+t;
else val++;
n=n/10;}
if(val==0) cout<<nr1;
else cout<<"IMPOSIBIL";
return 0;
}
Răspuns:
#include <iostream>
using namespace std;
int n,k,a,cif=0,x=0,ogl=0;
int main()
{
cin>>n>>k;
while (n>0)
{
a=n%10;
if(a<=k)
{x=x*10+a;
cif++;
n=n/10;}
else
n=n/10;
}
while(x>0)
{
ogl=ogl*10+x%10;
x=x/10;
}
if(cif!=0)
cout<<ogl;
else
cout<<"IMPOSIBIL";
return 0;
}