acm 查询
方法1:用vector做
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int temp,i,n,m; vector<int> v; while (cin>>n) { for (i=0;i<n;i++) { cin>>temp; v.push_back(temp); } cin>>m; for (i=0;i<m;i++) { cin>>temp; vector<int>::iterator index=find(v.begin(),v.end(),temp);//刚学的iterator迭代器用法,并使用系统提供的find方法 if (index==v.end()) { cout<<"NO"<<endl; } else { cout<<"YES"<<endl; } } } return 0; } Success comments (?) stdin copy Standard input is empty stdout Standard output is empty