Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- int a[5];
- int b[5];
- int c[10];
- int na, nb;
- fin >> na;
- for (int i = 0; i < na; i++)
- fin >> a[i];
- fin >> nb;
- for (int i = 0; i < nb; i++)
- fin >> b[i];
- int count = 0;
- for (int i = 0; i < na; i++)
- for (int j = 0; j < nb; j++)
- if (a[i] == b[j]) {
- c[count] = a[i];
- count++;
- b[j] = -100000000;
- }
- fout << count << '\n';
- for (int i = 0; i < count; i++)
- fout << c[i] << ' ';
- fout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment