Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <set>
  4. #include <string>
  5. using namespace std;
  6. bool Inters(string& line, char& elem) {
  7. for (size_t i = 0; i < line.size(); ++i) {
  8. if (line[i] == elem) {
  9. return true;
  10. }
  11. }
  12. return false;
  13. }
  14. int main() {
  15. string line;
  16. set<char> intersection;
  17. cin >> line;
  18. for (size_t i = 0; i < line.size(); ++i) {
  19. intersection.insert(line[i]);
  20. }
  21. while (cin >> line) {
  22. for (char i : intersection) {
  23. if (!Inters(line, i)) {
  24. intersection.erase(i);
  25. }
  26. }
  27. }
  28. if (intersection.size() >0) {
  29. for (auto i : intersection) {
  30. cout << i << endl;
  31. }
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement