STL之pair对组

 1 #include<iostream>
 2 #include<algorithm>
 3 #include<cstring>
 4 #include<cstdlib>
 5 using namespace std;
 6 
 7 //创建对组
 8 void test01(){
 9     /*方法一:*/
10     pair<int,int> pair1(10,20);
11     cout<<pair1.first<<" "<<pair1.second<<endl;
12     /*方法二:*/
13     pair<int,string> pair2=make_pair(10,"aaa");
14     cout<<pair2.first<<" "<<pair2.second<<endl;
15     /*方法三:*/
16     pair<int,string> pair3=pair2;
17 
18 }
19 int main(){
20 
21     test01();
22     return 0;
23 }

猜你喜欢

转载自www.cnblogs.com/Bravewtz/p/10325801.html