当前位置:网站首页>Map uses tuple to realize multiple value values
Map uses tuple to realize multiple value values
2022-07-28 07:20:00 【▀】
#include<iostream>
#include<string>
#include<tuple>
#include<map>
using namespace std;
void show(map<int, tuple<int, int, string>>&m)
{
map<int, tuple<int, int, string>>::iterator te = m.begin();
while (te!=m.end())
{
cout << (*te).first << "\t" << get<0>((*te).second) << "\t" << get<1>((*te).second) << "\t" << get<2>((*te).second) << endl;
te++;
}
}
void Display(map<int,string>&m)
{
map<int, string>::iterator te = m.begin();
while (te!=m.end())
{
cout << (*te).first << "\t" << (*te).second << endl;
te++;
}
}
int main()
{
map<int, string>mymap;
pair<int, string>s1(1,"zhangsan");
pair<int, string>s2(2,"lisi");
pair<int, string>s3(3,"wangwu");
pair<int, string>s4(4,"zhaoliu");
pair<int, string>s5(5,"zhangsan");
mymap.insert(s1);
mymap.insert(s2);
mymap.insert(s3);
mymap.insert(s4);
mymap.insert(s5);
cout << "pair<int,string>" << endl;
Display(mymap);
map<int,tuple<int,int,string>> ms;
tuple<int, int, string>t1(1001,22,"zhangsan");
tuple<int, int, string>t2(1002, 22, "lisi");
tuple<int, int, string>t3(1003, 22, "wanger");
tuple<int, int, string>t4(1004, 19, "zhaoliu");
ms.insert(pair<int, tuple< int, int , string>>(20,t1));
ms.insert(pair<int, tuple<int, int, string>>(30, t2));
ms.insert(pair<int, tuple<int, int, string>>(40, t3));
ms.insert(pair<int, tuple<int, int, string>>(50, t4));
cout << endl;
cout << "pair<int, tuple<int, int, string>> many value Pass on " << endl;
show(ms);
cin.get();
return 0;
}test result :

边栏推荐
- Shell--- sed statement exercise
- Review of C language (variable parameters)
- Standard C language summary 2
- Basic usage and precautions of arrow function (= >) and three-point operator (...) in ES6 (this points to)
- Add, delete, check and modify linked lists
- anaconda3无法打开navigator的解决办法
- C language maze
- 隔离级别RR、间隙锁、幻读
- 登录heroku出现 IP address mismatch的解决方案
- Two horizontal and vertical screen switching schemes for uniapp mobile terminal
猜你喜欢
随机推荐
Review of C language (byte alignment)
object detection
Reptile learning summary
最早截止时间优先(EDF)
codesensor:将代码转化为ast后再转化为文本向量
Basic knowledge of video format: let you know MKV, MP4, h.265, bit rate, color depth, etc
shell---条件语句练习
VLAN configuration
Generate create table creation SQL statement according to excel
Sysevr environment configuration: joern-0.3.1, neo4j-2.1.5, py2neo2.0
Static and floating routes
JS data type detection and modification detection
freemarker导出word,带表格和多张图片,解决图片重复和变形
guava之Retryer
Neo4j running error occurred during initialization of VM incompatible minimum and maximum heap sizes spec
vcf文件制作
Two horizontal and vertical screen switching schemes for uniapp mobile terminal
登录heroku出现 IP address mismatch的解决方案
低端电脑如何深度学习秘籍-使用mistGPU计算平台
flow_ x+flow_ y---RGB








