One, Title Description
Second, problem-solving ideas
Do two bool
types of hash table records can be initialized to false
, the traversal is true to the array elements, output index
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
unsigned int N1, N2;
vector<bool> Hash1(1001, false);
vector<bool> Hash2(1001, false);
cin >> N1;
unsigned int tmp;
for (unsigned int i = 0; i < N1; i++)
{
cin >> tmp;
Hash1[tmp] = true;
}
cin >> N2;
for (unsigned int i = 0; i < N2; i++)
{
cin >> tmp;
Hash2[tmp] = true;
}
for (unsigned int i = 0; i < 1001; i++)
{
if (Hash1[i] == true)
cout << i << endl;
}
for (unsigned int i = 0; i < 1001; i++)
{
if (Hash2[i] == true)
cout << i << endl;
}
return 0;
}