[c++]代码库
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int i, search_value,pause, ia[9]= {47,29,37,23,11,7, 5, 31, 41};
void ff();
int main()
{
while(1)
ff();
return 0;
}
void ff()
{
vector<int> vec(ia, ia+9);
vector<int> ::iterator iter;
for(i= 0;i < vec.size(); i++)
cout<< vec[i]<<'\t';
cout<<endl;
vec.push_back(13);
for(iter = vec.begin(); iter!= vec.end(); iter++)
cout<<*iter<<'\t';
cout<<"\n input number you want search: ";
cin>>search_value;
iter = find(vec.begin(), vec.end(),search_value);
cout<<"number: "<<search_value<<(iter == vec.end()? " No " : " Yes ")<<endl;
}
[代码运行效果截图]