当前位置:网站首页>map使用tuple实现多value值
map使用tuple实现多value值
2022-07-28 05:30: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>>多value传递" << endl;
show(ms);
cin.get();
return 0;
}测试结果:

边栏推荐
- DNS域名解析
- A timed task reminder tool
- Media set up live broadcast server
- 关于正则的教程
- MySQL queries all descendant nodes under the parent node. When querying the user list, it is processed by multi-level (company) departments. According to reflection, it recurses the tree structure too
- JS string method Encyclopedia
- Asynchronous programming promise
- Understanding of maximum likelihood estimation, gradient descent, linear regression and logistic regression
- Uni app double click event simulation
- Canvas drawing 1
猜你喜欢

爬虫学习总结

DHCP service

Shell--第一天作业

Shell--- function

VNC Timed out waiting for a response from the computer

VLAN configuration

rsync+inotify实现远程实时同步

freemarker合并单元格,if、else标签的使用,null、空字符串处理

MOOC Weng Kai C language fourth week: further judgment and circulation: 3. Multiple branches 4. Examples of circulation 5. Common errors in judgment and circulation

joern运行后.joernindex数据库无内容
随机推荐
YUM仓库的搭建
As a result, fill in the birthday candles
MOOC Weng Kai C language week 3: judgment and cycle: 1. Judgment
ES6 add -- > object
Method of decomposing path into directory name and file name
Freemaker merges cells, uses if and else tags, and processes null and empty strings
Install Nessus under Kali
Canvas drawing 1
kali下安装nessus
Small turtle C (Chapter 6 arrays 1 and 2)
Asynchronous programming promise
Three cache technologies -- localstorage, sessionstorage, cookies
视频格式基础知识:让你了解MKV、MP4、H.265、码率、色深等等
Codesensor: convert the code into AST and then into text vector
Reptile learning summary
Leetcode then a deep copy of the linked list
Blue Bridge Cup square filling number
Svg understanding and drawing application
Standard C language learning summary 8
DHCP服务