-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPairs.cpp
More file actions
46 lines (35 loc) · 1.2 KB
/
Pairs.cpp
File metadata and controls
46 lines (35 loc) · 1.2 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
// used to combine two entity
// declare a data with two pair
/*
default constructor use 0 0 for int
string for empty string
*/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
pair<int, char> pair1;
pair<int, int> pair2(10, 20);
pair<int, char> p2;
pair<int, string> p1;
p1 = {10, "twitter"};
pair1.first = 100;
pair1.second = 'G';
cout << pair1.first << " ";
cout << pair1.second << " "
<< "\n";
cout << pair2.first << " " << pair2.second << "\n";
cout << p2.first << " " << p2.second << "\n";
cout << p1.first << " " << p1.second << "\n";
// function for make pair
pair<int, int> p3;
p3 = make_pair(100, 200);
cout << p3.first << " " << p3.second << "\n";
// comparision operators in pair comparison will be on first element in vector in heap
pair<int, int> l1(1, 23), l2(1, 42);
cout << (l1 == l2) << "\n"; // two values need to match
cout << (l1 != l2) << "\n"; // false is both same if anyone different then true
cout << (l1 > l2) << "\n"; // compare the first value if first values are same the n compare the second value
cout << (l1 < l2) << "\n"; // compare the first value
}