-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.cpp
33 lines (28 loc) · 832 Bytes
/
temp.cpp
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
// Created by ahmed on 1/29/2023.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
// Declaration
map <string, ll> mp;
// Declaration in DESC Order
map <string, ll, greater<string>> mp1;
// Initialization
map <string, ll> mp2 = {{"yousef", 11},
{"Mohamed", 21},
{"Ahmed", 21}};
// For each
// it.first > Key
// it.second > Value
for (auto it: mp) cout << it.first << " " << it.second << "\n";
// Iterator
map<string, ll>::iterator it = mp.begin();
for (it; it != mp.end(); ++it) {
cout << it->first << " ";
}
// Reverse Iterator
map<string, ll>::reverse_iterator it2 = mp.rbegin();
for (it2; it2 != mp.rend(); ++it2) {
cout << it2->first << " ";
}
}