文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > C++Primer 第10章-关联容器-课后习题答案
侵权投诉

C++Primer 第10章-关联容器-课后习题答案

C++Primer 第10章 关联容器 课后习题答案

第10章 关联容器

1.编写程序读入一些列string和int型数据,将每一组存储在一个pair对象中,然后将这些pair对象存储在vector容器里。

// 11.16_10.1_pair.cpp : 定义控制台应用程序的入口点。

//

#include "stdafx.h"

#include <iostream>

#include <string>

#include <vector>

#include <utility>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

string str;

int iVal;

cout << "\tInput some pair contents( pair<string, int > ) (^Z to end):\n"; vector< pair<string, int> > pairVec;

while( cin >> str >> iVal )

pairVec.push_back( pair< string, int > ( str, iVal) );

cout << "\n\t The content of pairVec is:\n" ;

for ( vector< pair<string, int> >::iterator it = pairVec.begin(); it != pairVec.end(); ++it ) {

cout << it->first << " " << it->second << endl;

}

system("pause");

return 0;

C++Primer 第10章-关联容器-课后习题答案

}

第1页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email