fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. string line1, line2, ans;
  8. while (cin >> line1 >> line2){;
  9. ans.clear();
  10. for(auto i : line1){
  11. for (int j = 0; j < line2.size(); ++j){
  12. if (i == line2[j]){
  13. ans += i;
  14. line2.erase(line2.begin() + j);
  15. --j;
  16. break;
  17. }
  18. }
  19. }
  20. sort (ans.begin(), ans.end());
  21. cout << ans <<'\n';
  22. }
  23. }
Success #stdin #stdout 0.01s 5432KB
stdin
pretty
women
walking
down
the
street
stdout
e
nw
et