-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathequal_pair.cpp
More file actions
38 lines (35 loc) · 847 Bytes
/
Copy pathequal_pair.cpp
File metadata and controls
38 lines (35 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <string>
#include <vector>
using std::string;
void get_pairs(const std::vector<int>& a,
const std::vector<int>& b,
const std::vector<int>& out) {
int cnt = 0;
int j = 0;
for (int i = 0; i < a.size(); i++) {
for (; j < b.size(); j++) {
if (a[i] == b[j]) {
cnt++;
break;
}
}
}
}
int main(int argc, char* argv[]) {
std::vector<int> a;
string s;
while (std::cin >> s)
a.push_back(std::atoi(s.c_str()));
std::vector<int> b;
while (std::cin >> s)
b.push_back(std::atoi(s.c_str()));
std::sort(a.begin(), a.end());
std::sort(b.begin(), b.end());
std::vector<int> out;
get_pairs(a, b, out);
std::cout << "equal pairs count: " << out.size() << std::endl;
for (auto i : out)
std::cout << i << std::endl;
return 0;
}