linux下練習 c++ 關聯式容器multimap特性

/*
multimap特性
key可以重復
不支持下標訪問
*/
#include<iostream>
#include<string>
#include "print.h"
#include<map>
using namespace std;
typedef pair<int,string>  pairmp;
typedef multimap<string,double> MS;int main()
{MS m;m.insert(MS::value_type("t1",1000));m.insert(MS::value_type("t1",1300));m.insert(make_pair("t2",3000));m.insert(MS::value_type("t1",1800));m.insert(make_pair("t2",100000));m.insert(MS::value_type("t1",1600));print(m.begin(),m.end());MS::iterator ib=m.begin(),ie;MS m2;while(ib!=m.end()){string name=ib->first;//first:K,second:Vie=m.upper_bound(name);//同一個key的一個區別上界double sum=0.0;while(ib!=ie){sum+=(ib++)->second;}m2.insert(make_pair(name,sum));//處理,并加入一個容量}print(m2.begin(),m2.end());return 0;
}


運行:

?

轉載于:https://www.cnblogs.com/pukuimin/archive/2012/10/25/2988091.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274546.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274546.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274546.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

一致性設計,而不是一致性

一致性設計重點 (Top highlight)If we ask any design system advocate what are the main reasons to build and maintain a design system, chances are ‘Consistency’ will come up as first or second in their list, together with the ‘A single source of truth’ po…

如何在 React 應用中使用 Hooks、Redux 等管理狀態

大家好&#xff0c;我是若川。持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系…

長語音識別體驗_如何為語音體驗寫作

長語音識別體驗重點 (Top highlight)“Voice User Interface (VUI) Designer” is an increasingly prominent job title in the tech world. A VUI designer typically writes the conversation and designs the flow between a VUI — an invisible interface that communica…

表連接

初學SQL表連接的時候&#xff0c;什么笛卡爾積&#xff0c;左連接&#xff0c;右連接看的頭都大了 后來看了《SQL Server技術內幕2008&#xff1a;T-SQL查詢》之后&#xff0c;豁然開朗。今天寫數據庫又用到了表連接&#xff0c;印象有點模糊了&#xff0c;趕緊找地方寫下來先。…

分析了1011個程序員的裁員情況后得出的啟示

大家好&#xff0c;我是若川。持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系…

定義設計系統

System is “the whole creation, the universe,” from Late Latin systema “an arrangement, system,” from Greek systema “organized whole, a whole compounded of parts”.系統是晚期拉丁語系統的“整體創造物&#xff0c;宇宙”&#xff0c;是希臘語系統的“一種安排…

如何備份linux系統(轉)

如何備份linux系統 不像Windows&#xff0c;Linux不限制根用戶存取任何東西&#xff0c;因此&#xff0c;你完全可以把一個分區上每一個的文件放入一個TAR文件中。來實施這一方法&#xff0c;用這個成為根用戶&#xff1a;sudo su接著去你的文件系統的根目錄&#xff08;在我們…

2w行代碼、200個實戰項目,助你修煉5大編程基本功。【送書《設計模式之美》】...

大家好&#xff0c;我是若川。之前送了很多書&#xff0c;現在又和異步圖書合作再次爭取了幾本書&#xff0c;具體送書規則看文末。所謂練武不練功&#xff0c;到老一場空&#xff0c;以技術為驅動的程序員同樣如此。面向對象編程范式、設計原則、代碼規范、重構技巧和設計模式…

C++第10周項目2擴展之2參考——迭代求和

課程首頁地址&#xff1a;http://blog.csdn.net/sxhelijian/article/details/7910565【項目2擴展之2&#xff08;選做&#xff09;】計算下面的式子&#xff0c;不能使用求冪函數pow()式一&#xff1a;#include <iostream> using namespace std; int main( ) { int i,m1;…

swift自行車品牌介紹_品牌101:簡介

swift自行車品牌介紹Sometimes when I’m around designer friends and there’s a lull in the conversation one of us will blurt out, “What is branding, anyway?” Then we shrug our shoulders and chuckle, knowing that the answer is far too complex to sum up in…

flutter 透明度動畫_Flutter中的動畫填充+不透明度動畫?

flutter 透明度動畫Flutter SDK provides us with many widgets which help us in animating elements on screen easily by implicitly managing the animations i.e. we need not worry about creating and managing intances of AnimationController during the lifecycle o…

阿里 P10 是怎樣的存在?

談起中國頂尖的程序員&#xff0c;很多人首先會想到之前的雷軍、張小龍&#xff0c;還有現在的多隆、行癲、道哥等人&#xff0c;但今天我想聊一聊的這位大神&#xff0c;他的技術成就也同樣令人矚目。19 年獲得國家技術發明二等獎、20 年獲得國家計算機協會頒發的“ CCF 杰出工…

vba交付圖表設計_您是在為交付目的而“設計”嗎?

vba交付圖表設計重點 (Top highlight)It’s a regular Monday morning. All the design team is organizing the tasks for the ongoing week and reviewing requirements and deadlines for the various projects at the studio or company you work at. Suddenly, among the …

正則表達式限制文本框只能輸入數字

許多時候我們在制作表單時需要限制文本框輸入內容的類型&#xff0c;下面我們用正則表達式限制文本框只能輸入數字、小數點、英文字母、漢字等各類代碼。 1.文本框只能輸入數字代碼(小數點也不能輸入) <input οnkeyup"this.valuethis.value.replace(/\D/g,)" …

前端必讀書籍推薦

大家好&#xff0c;我是若川。持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系…

window程序設計學會_是時候我們學會設計合適的餅圖了

window程序設計學會Pie charts are common in data science — next to the 餅形圖在數據科學中很常見- bar chart and the line plot, the pie chart is incredibly standard and simple. A circle is split into several slices, with each slice’s angle representing how…

「非廣告」程序員如何才能盡量避免被裁?

大家好&#xff0c;我是若川。持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 ruochuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試系…

使用css制作三角,兼容IE6,用到的標簽divsspan

使用css來制作三角&#xff0c;在日常用得較多。恰好這幾天項目中有用到&#xff0c;之前只是從網上copy下來代碼直接用&#xff0c;但是今天在用的時候遇到一些問題&#xff0c;于是借此機會把這個css繪制三角好好研究下吧。 我們分別寫一個<div>,<s>,<span>…

培訓師 每小時多少錢_每個產品設計師需要了解的品牌知識

培訓師 每小時多少錢重點 (Top highlight)These days, it pays to know about brand. The rise of startups has created thousands of new brand design opportunities, and people of all disciplines are working to help brands compete in a crowded world. Increasingly,…

Android 綁定遠程服務出現 Not Allowed to bind service

E/AndroidRuntime(3783): Caused by: java.lang.SecurityException: Not allowed to bind to service Intent { actcom.lenovo.pleiades.conntek.pad } 主要原因是服務中設有簽名保護&#xff0c;該服務上一次是通過A設備中的Eclipse簽名的&#xff0c;這一次是通過B設備中的Ec…