pair

 1 /*
 2    当需要将两个数据合成一个数据是或当一个函数需要返回两个数据,
 3    相当于一个结构体,存的两个变量是first,second,可以直接使用
 4     
 5 */
 6 #include<iostream>
 7 using namespace std;
 8 typedef pair<int ,int > p;//由于pair使用时比较繁琐
 9                           //故用typedef或者define来简化
10                           //即打代码时只需要打p
11                           //而不需要打全部 
12 int n,m;
13 int main(){
14     cin>>n>>m;
15     p p1;//p类似于于int 定义变量用 
16     p1=make_pair(n,m);//make_pair()赋值 
17     cout<<p1.first <<endl;
18     cout<<p1.second ;
19     return 0;
20 } 
原文地址:https://www.cnblogs.com/nvwang123/p/10776679.html