Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <set>
- #include <vector>
- #include <string>
- #include <iterator>
- #include <algorithm>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- string s;
- vector <string> v, result;
- multiset <char> set1, set2;
- set <string> U;
- while (!in.eof())
- {
- getline(in, s);
- v.push_back(s);
- }
- for (int i = 0; i < v.size(); i++)
- {
- set <char> c1 = { '?' };
- set <char> c2 = { '!' };
- for (int j = 0; j < s.length(); j++)
- {
- if ((ispunct(s[j])) && (c1.count(s[j]) == 1))
- {
- for (int k = 0; k < j; k++)
- {
- set1.insert(s[k]);
- }
- }
- if ((ispunct(s[j])) && (c2.count(s[j]) == 1))
- {
- for (int h = 0; h < j; h++)
- {
- set2.insert(s[h]);
- }
- }
- }
- }
- set<string>::iterator it;
- set_intersection(set1.begin(), set1.end(), set2.begin(), set2.end(), inserter(U, U.begin()));
- for (auto it : U)
- {
- out << it << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment