4、编程实践 练习:编写程序读入一系列string和int型数据,将每一组存储在一个pair对象中,然后将这些pair对象存储在vector容器 #include<iostream> #include<string> #include<vector> #include<utility> using namespace std; int main() { pair<string, int>p; typedef vector< pair<string, int> > VP; VP vp; while(cin>>p.first>>p.second) { vp.push_back(make_pair(p.first,p.second)); } VP::iterator it; for(it=vp.begin(); it!=vp.end(); it++) cout<<it->first<<","<<it->second<<endl; return 0; }
pair
猜你喜欢
转载自blog.csdn.net/guozuofeng/article/details/80140796
今日推荐
周排行