desiP

Untitled

Oct 10th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <string>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. string a,b;
  12. cin >> a >> b;
  13.  
  14. sort(a.begin(), a.end());
  15. sort(b.begin(), b.end());
  16.  
  17. string c;
  18. int s = -1;
  19. for(int i = 0, j = 0; i < sizeof(a) || j < sizeof(b);){
  20. if(s == -1 || (a[i] == b[j] && a[i] != c[s])){
  21. c+=a[i];
  22. s++;
  23. }
  24. else if(a[i] > b[j]){
  25. j++;
  26. }
  27. else{
  28. i++;
  29. }
  30. }
  31. cout << c;
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment