![]() |
#2
玉垒浮云2012-12-10 09:20
|
#include<iostream>
#include<vector>
#include<string>
using namespace std;
struct information
{
string name;
int number;
string address;
};
int main()
{
vector<information>aa;
information temp;
int n;
cout<<"please input the amount of pepole"<<endl;
cin>>n;
for(int i=0;i!=n;++i)
{
cin>>temp.name>>temp.number>>temp.address;
aa.push_back(temp);
}
for(vector<information>::iterator j=aa.begin();j!=aa.end();++j)
{
cout<<(*j).name<<" "<<(*j).number<<" "<<(*j).address<<endl;
}
cout<<"please input name you want to look for"<<endl;
string name1;
cout<<"please input name1"<<endl;
cin>>name1;
for(vector<information>::iterator k=aa.begin();k!=aa.end();++k)
{
if((*k).name==name1)
cout<<(*k).name<<(*k).number<<(*k).address<<endl;
}
return 0;
}
这是我的代码,缺一个按字典排序的功能,请大神指教