title: c++ - How to get first and second element of pair if used as key in map?
body: <p>I was trying to get first and second element of pair when i am using pair as key in map.For better clarification please see code below.This is what i have tried</p>
  
  <pre><code>#include &lt;bits/stdc++.h&gt;
  using namespace std;
  
  int main() 
  {
  // your code goes here
  map&lt;pair&lt;int,int&gt;,int&gt;mp;
  int n;
  cin&gt;&gt;n;
  int a[n];
  for(int i=0;i&lt;n;++i)cin&gt;&gt;a[i];
  int y=0;
  for(int i=0;i&lt;n;++i)
  {
      mp.insert(make_pair(y,a[i]));
      y=a[i]+1;
  }
  int m;
  cin&gt;&gt;m;
  int q[m];
  for(int i=0;i&lt;m;++i)cin&gt;&gt;q[i];
  for(int i=0;i&lt;m;i++)
  {
      int temp=q[i];
      for(map&lt;pair&lt;int,int&gt;,int&gt;::iterator it=mp.begin();it!=mp.end();++it)
      {
          if(((it-&gt;first)&lt;=temp)&amp;&amp;((it-&gt;second)&gt;=temp))
          cout&lt;&lt;mp-&gt;second&lt;&lt;endl;
      }
  
    }
    return 0;
  }
  </code></pre>
  
  <p>I want to get first and second element of key here.How can i do that ?</p>