标签:end for turn bsp ++i cto find tor tmp
#include <cstdio>
#include <set>
#include <vector>
using namespace std;
int main()
{
set<int> first_array;
int m, n;
scanf("%d", &m);
int tmp;
for (int i = 0; i < m; i++)
{
scanf("%d", &tmp);
first_array.insert(tmp);
}
scanf("%d", &n);
vector<int> ans;
for (int i = 0; i < n; i++)
{
scanf("%d", &tmp);
//当set集合中没有tmp时,find方法将会返回end() 值
if (first_array.find(tmp) != first_array.end())
{
ans.push_back(tmp);
}
}
for (int i = 0; i < ans.size(); ++i)
{
printf("%d%c", ans[i], ‘ ‘);
}
return 0;
}
标签:end for turn bsp ++i cto find tor tmp
原文地址:http://www.cnblogs.com/qingtianBKY/p/6731189.html