上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 99 下一页

2011年7月29日

set

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <set>#include <iostream>#include <algorithm>using namespace std;int main( ){ set<int>s1,s2,c,d,e; int i, j; for (i = 0; i < 10; i++) s1.insert(i); for (i = 5; i < 1 阅读全文

posted @ 2011-07-29 01:03 more think, more gains 阅读(185) 评论(0) 推荐(0) 编辑

2011年7月28日

本文来自CSDN博客 map

摘要: stl里map函数声明:本文转自http://blog.csdn.net/sun_top/archive/2009/05/25/4213406.aspx C++ Maps(关联容器) map类定义了一个关联容器,并且在容器中使用唯一的关键字(任何两个元素的键都不相同)来映射相应的值。从本质上来说,关键字就是值的名字。在map对象中存储了一个值之后,就可以通过关键字来获得它。map对象是一系列关键字/值的匹配对。 map的主要功能在于:只有你知道了一个值的关键字,就能够找到这个值。例如,定义一个map对象m,在该对象中使用人名作为关键字,并将每个人的电话号码存储为值。那么可以使用m[“张三”]表 阅读全文

posted @ 2011-07-28 23:53 more think, more gains 阅读(235) 评论(0) 推荐(0) 编辑

map 运算符重载

摘要: #include <stdio.h>#include <map>#include <string>#include <algorithm>#include <iostream>using namespace std;typedef struct studentinfo{ int ID; string strName; bool operator < (studentinfo const & A) const { if (ID < A.ID ) return true; if (ID == A.ID) return 阅读全文

posted @ 2011-07-28 23:43 more think, more gains 阅读(603) 评论(0) 推荐(0) 编辑

map erase clear

摘要: #include <stdio.h>#include <map>#include <string.h>#include <algorithm>#include <iostream>using namespace std;int main( ){ map<int,string>mp; mp[1] = "abc"; mp[2] = "bcd"; mp[3] = "efg"; map<int,string>::iterator iter; iter = mp 阅读全文

posted @ 2011-07-28 23:06 more think, more gains 阅读(336) 评论(0) 推荐(0) 编辑

lower_bound upper_bound

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <map>#include <algorithm>using namespace std;int main( ){ //lower_bound函数用法,这个函数用来返回要查找关键字的下界 //upper_bound函数用法,这个函数用来返回要查找关键字的上界 map<int,string>mp; mp[0]="abcdefg0" 阅读全文

posted @ 2011-07-28 22:14 more think, more gains 阅读(190) 评论(0) 推荐(0) 编辑

上一页 1 ··· 48 49 50 51 52 53 54 55 56 ··· 99 下一页

导航