Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <set>
- #include <string>
- using namespace std;
- bool Inters(string& line, char& elem) {
- for (size_t i = 0; i < line.size(); ++i) {
- if (line[i] == elem) {
- return true;
- }
- }
- return false;
- }
- int main() {
- string line;
- set<char> intersection;
- cin >> line;
- for (size_t i = 0; i < line.size(); ++i) {
- intersection.insert(line[i]);
- }
- while (cin >> line) {
- for (char i : intersection) {
- if (!Inters(line, i)) {
- intersection.erase(i);
- }
- }
- }
- if (intersection.size() >0) {
- for (auto i : intersection) {
- cout << i << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement