当前位置:网站首页>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 --- conditional statement practice
- Basic usage and precautions of arrow function (= >) and three-point operator (...) in ES6 (this points to)
- Understanding of maximum likelihood estimation, gradient descent, linear regression and logistic regression
- uniapp项目怎么连接手机真机调试
- RAID disk array
- N天前的日期
- 登录heroku出现 IP address mismatch的解决方案
- 最早截止时间优先(EDF)
- Standard C language summary 1
- Add, delete, check and modify linked lists
猜你喜欢

guava之guava cache

Rsync+inotify to realize remote real-time synchronization

高性能内存队列-Disruptor

easypoi导出隔行样式设置

VLAN configuration

guava之Retryer

Understanding of maximum likelihood estimation, gradient descent, linear regression and logistic regression

一个定时任务提醒工具

Generate create table creation SQL statement according to excel

Install pycharm
随机推荐
Joern's code uses -devign
Construction of Yum warehouse
Install pycharm
joern运行后.joernindex数据库无内容
Deployment of elk log analysis system
RAID disk array
shell---条件语句练习
shell---sed语句练习
vcf文件制作
短作业优先SJF
最近最久未使用
MySQL字段 不推荐使用 Null 的理由
Serial port configuration of raspberry pie
NoSQL之Redis配置与优化
Basic knowledge of video format: let you know MKV, MP4, h.265, bit rate, color depth, etc
easypoi导出隔行样式设置
Read the IP and device information of the switch node in the XML file, Ping the device, and the exception is displayed in the list
Easypoi export table with echars chart
高性能内存队列-Disruptor
PyTorch - Dropout: A Simple Way to Prevent Neural Networks from Overfitting