Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
852 B
4
Indexable
Never
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string a,b;
    while(getline(cin,a)&&getline(cin,b)){
            int MAX = 0;
            if(a==" "||b==" "){
                cout<<endl;
                continue;
            }
            int aa[26]={0},bb[26]={0};
           for(int i=0;i<a.length();i++){
                int tmp;
                tmp=a[i]-'a';
                aa[tmp]++;
            }
            for(int i=0;i<b.length();i++){
                int tmp2;
                tmp2=b[i]-'a';
                bb[tmp2]++;
            }
            for(int j=0;j<26;j++){
                    for(int i= 0 ; i<min(aa[j], bb[j]); i++) //有重複就輸出 
                        cout<<char('a'+j);
            }

                cout<<endl;
         }
            return 0;
    }