---
# System prepended metadata

title: UVa10252 - Common Permutation
tags: [UVa]

---

# UVa10252 - Common Permutation
[Prblem link](https://onlinejudge.org/external/102/10252.pdf)
## Review
### 空字串輸入
測資有空字串，所以要用`getline(cin,str);`
## Ans
```cpp=
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    while(getline(cin, a)&& getline(cin, b)){
        string ans="";
        for(int i=0;i<a.length();i++){
            for(int j=0;j<b.length();j++){
                if(a[i]==b[j]){
                    ans+=a[i];
                    b.erase(b.begin()+j);
                    break;
                }
            }
        }
        sort(ans.begin(),ans.end());
        cout<<ans<<endl;
    }
}
```