①pair<K,T> p 创建一个空的pair
②pair<K,T> p(first,second)创建一个包含两个元素的pair
③make_pair(first,second) 用first和second来创建pair
④ P < K 如果P.first < K.first或者!(p.first < k.first) && p.second < k.second
⑤ P == K。两个成员依次相等
⑥p.first p.second获得两个成员
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;
/************************************************************************
int main()
{
typedef pair<int,string> iStrPair;
iStrPair iStrPairOne;
int iFirst;
string strSecond;
vector<iStrPair> vtStrPair;
while (cin >> iFirst >> strSecond)
{
iStrPairOne = make_pair(iFirst,strSecond);
vtStrPair.push_back(iStrPairOne);
}
for (vector<iStrPair>::iterator it = vtStrPair.begin();it != vtStrPair.end(); ++it)
{
cout<< it->first <<" "<< it->second <<endl;
}
system("pause");
return 0;
}
****************************************************************************************/
int main()
{
vector<pair<int,string>> vtPair;
int iFirst;
string strSecond;
while (cin >> iFirst >> strSecond)
{
pair<int,string> iStrPair(iFirst,strSecond);
vtPair.push_back(iStrPair);
}
for ( int i = 0 ; i < vtPair.size() ; ++i)
{
cout<<vtPair.at(i).first<<" "<<vtPair.at(i).second<<endl;
}
system("pause");
return 0;
}