#include <iostream>
#include <vector>
#include <utility>
#include<string>
using namespace std;
void show(vector<pair<string, int> > &vec )
{
vector<pair<string, int> >::iterator it;
it = vec.begin();
while (it != vec.end())
{
cout << it->first.c_str()<<"\t"<<it->second << endl;
++it;
}
}
int main()
{
pair<string, int> ip;
string str;
int n;
vector<pair<string, int> > spvec;
cout << "Enter a string and an integer(ctrl+z to end):\n";
while (cin >> str >> n)
{
ip = make_pair(str, n);//
spvec.push_back(ip);
}
show(spvec);
return 0;
}
10.1 c++primer 第四版 习题10.1
最新推荐文章于 2021-10-06 16:08:17 发布