map最好不要在使用的时候删除东西

typedef map<int, int> templatemap;

templatemap AllScoreSort;

  for(int i=10000;i<10010;i++)

     AllScoreSort[i]=i+1;

  for (templatemap::iterator iter = AllScoreSort.begin(); iter!= AllScoreSort.end(); iter++)
  {
   int nRoleID = iter->first;
   int nScore = iter->second;
   if (10005 < nRoleID)
   {
    //AllScoreSort.erase(nRoleID);     //注意这行
    continue;
   }

   cout<<nRoleID<<" "<<nScore<<endl;
  }

原文地址:https://www.cnblogs.com/byfei/p/3112406.html