用法1:
生成一个pair
pair <int,int> temp;
用法二:
赋值
temp=14;
pari <int,int> x;
x=temp;
用法三:
访问
cout<<temp.first<<endl; //输出pair类型的结构体temp的第一个元素
cout<<temp.second<<endl; //输出第二个元素
用法四:
与map结合更好用:
map <pair<int,int>,int> temp;
pair <int,int> a;
a.first=13;
a.second=15;
temp [a] =147;
cout<<temp[a]<<endl;
用法五:
将 pair 与 优先队列结合起来使用优化 Dijkstra 算法。默认以 pair 的first元素来排序
priority_queue <pair <int, int>, vector <pair <int, int> >, greater <pair <int, int> > Q;