博客园 首页 私信博主 显示目录 隐藏目录 管理

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 }

 

posted @ 2019-01-27 10:59  Brave_WTZ  阅读(131)  评论(0编辑  收藏  举报