#include <iostream> #include <algorithm> using namespace std; int main() { string a,b,aux; int tama,tamb; while(getline(cin,a) && getline(cin,b)) { tama = a.size(); tamb = b.size(); sort(a.begin(),a.end()); sort(b.begin(),b.end()); string sol = ""; int i ,j = 0; for(i = 0; i<tama && j<tamb; i++) while(j<tamb && a[i]>=b[j]) { if(b[j]==a[i]) { sol += a[i]; j++; break; } j++; } cout << sol<<endl; } return 0; }
No hay comentarios:
Publicar un comentario