c++ STL之 multimap 的个性(权哥)
来源:互联网 发布:python web接口 编辑:程序博客网 时间:2024/05/17 22:13
/*multimap的个性:允许重复key元素是key/value对不支持方括号下标*/#include <map>#include <iostream>using namespace std;#include "print.h"#include <string>int main(){typedef multimap<string,double> MSD;MSD m;m.insert(MSD::value_type("WG",100000)); m.insert(make_pair("HJJ",120000)); m.insert(make_pair("YY",20000));m.insert(make_pair("HJJ",160000)); m.insert(make_pair("YY",3000));m.insert(MSD::value_type("WG",220000)); m.insert(MSD::value_type("WG",150000));m.insert(make_pair("HJJ",130000)); m.insert(make_pair("YY",1000000));m.insert(make_pair("YY",110000));print(m.begin(), m.end());MSD::iterator ib = m.begin(), ie;MSD cnt;while(ib!=m.end()){string name = ib->first;ie = m.upper_bound(name);double sum = 0.0;while(ib!=ie) sum += ib++->second;cnt.insert(make_pair(name,sum*0.03));}print(cnt.begin(),cnt.end());}/*输出:HJJ:120000 HJJ:160000 HJJ:130000 WG:100000 WG:220000 WG:150000 YY:20000 YY:3000 YY:1e+06 YY:110000 HJJ:12300 WG:14100 YY:33990 */
0 0
- c++ STL之 multimap 的个性(权哥)
- C++STL之multimap
- c++STL之multimap
- c++ STL之map的个性(权哥)
- c++ STL之 set 的个性(权哥)
- c++ STL之 multiset 的个性(权哥)
- C++STL之multimap多重映照容器
- STL之map&multimap容器(笔记)
- STL 之multimap
- STL之multimap简介
- STL之Multimap
- STL 之map,multimap
- STL之 multimap
- STL 之map,multimap
- stl之multimap容器
- stl之multiset,multimap
- STL之map&multimap
- STL之Multimap
- Java中String类应该注意的一些地方
- VS 2012 误删Microsoft Help Viewer 2.0 解决办法
- JNI调用64位dll
- linux文件操作-标准I/O操作--fgets与gets
- P问题 NP问题 和 NPC问题
- c++ STL之 multimap 的个性(权哥)
- 41-JavaScript-DOM-forms-imgs
- 视野覆盖
- (*(volatile unsigned long *)详解
- 浪费了半年时间,开始做论文了
- AMQP概念模型
- go内部实现
- Bluetooth stack from wiki
- 在XAMPP v3.2.1中,启动apache时,弹出“directive 'register_globals' is no longer availble in PHP”警告。