Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #include <string>
- #include <algorithm>
- #include <set>
- #include <vector>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main() {
- int n, a;
- cin >> n;
- set <int> s;
- set <int> s1;
- set <int> s2;
- vector <int> cis;
- for (int i = 0; i < n; i++) {
- cin >> a;
- cis.push_back(a);
- }
- for (int i = 0; i < n; i++) {
- for (int j = i + 1; j < n; j++) {
- int a = cis[i], b = cis[j];
- while (a > 0) {
- s1.insert(a % 10);
- a /= 10;
- }
- while (b > 0) {
- s2.insert(b % 10);
- b /= 10;
- }
- set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(), inserter(s, s.begin()));
- cout << i << "-" << j << ": ";
- for (auto x : s)
- cout << x << " ";
- cout << endl;
- s.clear();
- s1.clear();
- s2.clear();
- }
- cout << endl;
- }
- }
- 5
- 12 24 25 26 28
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement