-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpair.cpp
More file actions
34 lines (29 loc) · 708 Bytes
/
pair.cpp
File metadata and controls
34 lines (29 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<iostream>
#include<utility>
using namespace std;
int main()
{
pair<string,int> p1,p2;
cout << "Enter 2 space seperated strings\n";
string str;
cin>>str;
p1 = make_pair(str,str.length());
cin>>str;
p2 = make_pair(str,str.length());
cout<<"Pair 1: ("<<p1.first<<", "<<p1.second<<")"<<endl;
cout<<"Pair 2: ("<<p2.first<<", "<<p2.second<<")"<<endl;
swap(p1,p2);
cout << "After swaping :\n";
cout<<"Pair 1: ("<<p1.first<<", "<<p1.second<<")"<<endl;
cout<<"Pair 2: ("<<p2.first<<", "<<p2.second<<")"<<endl;
return 0;
}
/*
Enter 2 space seperated strings
werqw fdgdffsasdgfs
Pair 1: (werqw, 5)
Pair 2: (fdgdffsasdgfs, 13)
After swaping :
Pair 1: (fdgdffsasdgfs, 13)
Pair 2: (werqw, 5)
*/