当前位置:网站首页>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 :

边栏推荐
- 最短寻道时间优先(SSTF)
- Anaconda3 cannot open navigator solution
- caffe fine tune
- Neo4j运行报错Error occurred during initialization of VM Incompatible minimum and maximum heap sizes spec
- Record the first article of so and so Xiao Lu
- NAT network address translation
- Circular linked list problem
- Shell--- circular statement practice
- Sysevr environment configuration: joern-0.3.1, neo4j-2.1.5, py2neo2.0
- Event_ Loop event loop mechanism
猜你喜欢

object detection

win下安装nessus

Redis哨兵模式及集群

Rsync+inotify to realize remote real-time synchronization

Neo4j运行报错Error occurred during initialization of VM Incompatible minimum and maximum heap sizes spec

Nrf51822 review summary

WiFi one click connection configuration of raspberry pie

guava之EventBus

Starting point Chinese website font anti crawling technology web page can display numbers and letters, and the web page code is garbled or blank

Shell -- first day homework
随机推荐
Tailing microelectronics B91 general development board integrated into the trunk of openharmony community
guava之限流RateLimiter
guava之Retryer
Tutorial on regularization
Static and floating routes
开虚拟机KALI2022.2下安装GVM
Rsync+inotify to realize remote real-time synchronization
Serial port configuration of raspberry pie
Pytorch extracts the feature map of a certain layer
Standard C language learning summary 9
Starting point Chinese website font anti crawling technology web page can display numbers and letters, and the web page code is garbled or blank
build_ opencv.sh
Standard C language summary 2
guava之EventBus
TOPK problem
Implementation method of converting ast into word vector before converting word vector
Gd32f407 porting freertos+lwip
map使用tuple实现多value值
Standard C language learning summary 5
Freemaker exports word with tables and multiple pictures to solve the repetition and deformation of pictures