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 阅读(263) 评论(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 阅读(611) 评论(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 阅读(338) 评论(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 阅读(199) 评论(0) 推荐(0)

map find

摘要: #include <stdio.h>#include <iostream>#include <stdlib.h>#include <map>using namespace std;int main( ){ map<int,string>mp; mp[0] = "beijing"; mp[1] = "shanghai"; mp[2] = "shenzhen"; map<int,string>::iterator iter; iter = mp.find(1); if 阅读全文

posted @ 2011-07-28 21:59 more think, more gains 阅读(147) 评论(0) 推荐(0)

map 查找1

摘要: #include <stdio.h>#include <string.h>#include <algorithm>#include <map>#include <stdlib.h>#include <iostream>#include <string>using namespace std;int main( ){ map<string,int>mp; mp.insert(pair<string,int>("beijing",50)); mp.insert(pair& 阅读全文

posted @ 2011-07-28 21:49 more think, more gains 阅读(183) 评论(0) 推荐(0)

stl map3

摘要: #include <stdio.h>#include <iostream>#include <map>#include <algorithm>using namespace std;int main( ){ //用insert函数插入value_type 数据 map<int,string>stu; int n, i; stu.insert(map<int,string>::value_type(1,"bcdefg")); stu.insert(map<int,string>::value_ 阅读全文

posted @ 2011-07-28 21:38 more think, more gains 阅读(148) 评论(0) 推荐(0)

小白 stl map

摘要: #include <iostream>#include <map>#include <vector>#include <string>#include <algorithm>#include <queue>using namespace std;#define INF 0x7f7f7f7fint N, cnt, beg, end, v;int g[155][155], res[155]; char s[33], e[33]; map <string, int> mp;struct Bus { int pos, 阅读全文

posted @ 2011-07-28 21:06 more think, more gains 阅读(169) 评论(0) 推荐(0)

stl map2

摘要: #include <stdio.h>#include <map>#include <iostream>using namespace std;// 用insert插入数据时,当map中有这个关键字时,insert是插入不了的数据的。// 但用数组它可以覆盖以前关键字对应的值int main( ){ map<int,string> stu,stu2; stu[1] = "boy1"; stu[1] = "boy2"; stu[2] = "boy3"; map<int,string&g 阅读全文

posted @ 2011-07-28 21:04 more think, more gains 阅读(107) 评论(0) 推荐(0)

stl map

摘要: #include <stdio.h>#include <map>#include <iostream>using namespace std;int main( ){ map<int, string>stu; int a, b, i, j; char str[20]; while (scanf("%d",&a) != EOF ) { for (i = 0; i < a; i++) { scanf("%d%s",&b,str); //stu[b] = str; stu.insert(ma 阅读全文

posted @ 2011-07-28 20:13 more think, more gains 阅读(145) 评论(0) 推荐(0)

SORT AGAIN 看错题意啦。wa了好几次。。5555555

摘要: 一个组合数为第K大是指有K-1个不同的组合数小于它。#include <stdio.h>#include <string.h>#include <algorithm>#include <math.h>int A[5100];int B[10100];int main( ){ int T, N, k, max , t, num, i, j; scanf("%d",&T); while(T--) { num = 0; max = 0; memset(B, 0, sizeof(B)); scanf("%d%d&qu 阅读全文

posted @ 2011-07-28 15:58 more think, more gains 阅读(152) 评论(0) 推荐(0)

排列2 pe了好几次。。悲剧

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;int main( ){ char str[10], ch[10]; int len, flag, a[10], i, flag1, k = 0; while (1) { flag1 = 0; for ( i = 0; i < 4; i++) scanf("%d",&a[i]), str[i] = a[i] + '0 阅读全文

posted @ 2011-07-28 10:09 more think, more gains 阅读(173) 评论(0) 推荐(0)

AC

摘要: A CTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1741Accepted Submission(s): 1089Problem DescriptionAre you excited when you see the title "AC" ? If the answer is YES , AC it ;You must learn these two combination formulas in the school 阅读全文

posted @ 2011-07-28 09:16 more think, more gains 阅读(177) 评论(0) 推荐(0)

导航