#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main(){ int T; cin>>T; while(T--){ char a[999],b[999],c[999]; cin>>a>>b; int k=0; for(int i=0;i<strlen(a);i++){ for(int j=0;j<strlen(b);j++){ if(a[i]==b[j]){ c[k++]=b[j]; b[j]='#'; break; } } } if(k==0){ cout<<"-1"<<endl; } else{ sort(c,c+k); cout<<c; cout<<endl; } } return 0; } /* Main.cc: In function 'int main()': Main.cc:12:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0;i<strlen(a);i++){ ^ Main.cc:13:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j=0;j<strlen(b);j++){ ^ Main.cc:25:19: error: 'sort' was not declared in this scope sort(c,c+k); ^ */ |
Double click to view unformatted code.