title: I want to reverse the values of map and print it using range based for loop.
body: <p>I have done the programming but it is not reversing. I have used a different map to put the values in reverse order,but it still shows the same. My main question was to traverse backward and print the values using range based loop.</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include&lt;conio.h&gt;
  #include &lt;stdio.h&gt;
  #include&lt;vector&gt;
  #include&lt;map&gt;
  #include&lt;utility&gt;
  #include&lt;set&gt;
      map&lt;int, int&gt;m1;
          for (int i = 1; i &lt;= 100; ++i)
          {
              m1.insert({ i,i });
          }
  
      for (const auto &amp;y :m1)
      {
          cout &lt;&lt;"("&lt;&lt; y.first &lt;&lt; "  "&lt;&lt;y.second &lt;&lt; ")" &lt;&lt;"  " ;
      }
      cout &lt;&lt; endl &lt;&lt; endl;
      map&lt;int, int&gt;m2;
      map&lt;int, int&gt;::reverse_iterator iter;
  
      for (auto iter = m1.rbegin(); iter != m1.rend(); ++iter)
      {
          m2.insert({ iter-&gt;first,iter-&gt;second });
  
      }       
     for (const auto &amp;y : m2)
      {
          cout &lt;&lt; "(" &lt;&lt; y.first &lt;&lt; "  " &lt;&lt; y.second &lt;&lt; ")" &lt;&lt; "  ";
      }
  </code></pre>