3.1
Copied!
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<char, int> mymap;
map<char, int>::iterator itlow, itup;
pair<map<char, int>::iterator, map<char, int>::iterator> ret, make_ret;
mymap['a'] = 101; mymap['c'] = 303; mymap['f'] = 404; mymap['b'] = 202;
cout << mymap.count('c') << endl;
cout << mymap.find('c')->second << endl;
ret = mymap.equal_range('b');
char key = 'b';
make_ret = make_pair(mymap.lower_bound(key), mymap.upper_bound(key));
cout << "Kichik boʻlmagam element: ";
cout << ret.first->first << " => " << ret.first->second << '\t';
cout << make_ret.first->first << " => " << make_ret.first->second << '\t';
itlow = mymap.lower_bound('b');
cout << itlow->first << " => " << itlow->second << endl;
cout << "katta boʻlgan birinchi element: ";
cout << ret.second->first << " => " << ret.second->second << '\t';
cout << make_ret.second->first << " => " << make_ret.second->second << '\t';
itup = mymap.upper_bound('b');
cout << itup->first << " => " << itup->second << endl;
system("pause");
return 0;
}
Run on cpp.sh
Copied!