41(c++). MAP stl
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define lg long long
# define fi(i,L,R) for (int i = L ; i <= R ; i++)
# define fd(i,R,L) for (int i = R ; i >= L ; i--)
#define s1 string
#define p_b push_back
#define st sort(a,a+n)
#define rev reverse(a,a+n)
#define revs(j) reverse((j).begin(),(j).end())
#define srt(k) sort((k).begin(),(k).end())
#define suni s.erase(unique(s.begin(),s.end()),s.end())
#define vuni v.erase(unique(v.begin(),v.end()),v.end())
int main()
{
ll t; cin>>t; while(t--)
{
/* map<s1,ll>m;
map<s1,ll>::iterator it;
m["dipta"]=43;
m["arnob"]=42;
m["arnob"]=42;
m["nabil"]=41;
//it=m.begin();
//++it;
//cout<<it-> second <<endl; // first for accessing first
// column second for accessing second column and iterator indicated rows .
for(it=m.begin(); it!=m.end();++it)
{
cout<<it->first<< " "<<it->second<<endl;
}*/
map<int,int>mp;
//map<int,int>::iterator it;
mp.insert({1,10}) ; // mp[1]=10
mp.insert({2,20});
mp.insert({5,30});
mp.insert({4,40});
mp.insert({1,50});
// cout<<mp.at(2)<<endl;
/* for(auto it: mp)
{
cout<<it.first<<" "<<it.second<<endl; // for printing map .
}*/
// we can also use iterator for printing map .
/* for(it=mp.begin();it!=mp.end();it++)
{
cout<<it->first<<" "<<it->second<<endl;
}*/
// cout<<mp.size()<<endl;// indicates pair's number.
//mp.clear();// now map is empty ,no pair or element.
// if(mp.empty()) cout<<"0"<<endl;
// else cout<<"1"<<endl;
/* map<int,string>mp;
mp.insert({1,"abab"});
mp.insert({2,"bbab"});
mp.insert({4,"dbab"});
mp.insert({3,"cbab"});*/
//mp.erase(1);// delete value of index 1,including its index.
//int cnt=mp.count(1);
//cout<<cnt<<endl;
//auto it = mp.find(2);
//if(it!=mp.end()) cout<<"0"<<endl;
//else cout<<"1"<<endl;
//auto it=mp.lower_bound(1);
//cout<<(*it).first<<" "<<(*it).second<<endl;
//auto it=mp.upper_bound(2)
}
return 0;
}
Comments
Post a Comment