题解 | #求长方体表面积#
判断元素是否出现
http://www.nowcoder.com/practice/0787459e92bc4360ba48b094b7f21577
#include<bits/stdc++.h>
#include<map>
using namespace std;
int main() {
//write your code here......
map<int,string>ma;
map<int,string>::iterator it;
int m,n,x;
cin>>n>>m;
//导入map数据结构用insert
while(n--){
cin>>x;
ma.insert(pair<int,string>(x,"yes"));
}
while(m--){
cin>>x;
it = ma.find(x);//查找map中是否有x键的元素,有则返回该元素位置,没有则返回map.end()
if (it == ma.end()) cout<<"no"<<endl;
// else cout<<it->second<<endl;//也可以
else cout<<"yes"<<endl;
}
return 0;
}