C++ STL小练习

#include<iostream>
#include<map>

typedef std::map<std::pair<int,int>,int>Dict;
typedefDict::const_iterator It;

int main()
{
   
Dict d;

   d
[std::make_pair(0,0)]=0;
   d
[std::make_pair(1,2)]=1;
   d
[std::make_pair(2,1)]=2;
   d
[std::make_pair(2,3)]=3;
   d
[std::make_pair(3,2)]=4;

   
for(It it(d.begin()); it != d.end();++it)
   
{
     
int i(it->first.first);
     
int j(it->first.second);
      std
::cout <<it->second <<' '
               
<<d[std::make_pair(j, i)]<<'\n';
   
}
}
posted @ 2011-11-21 19:31  Thomas Hwang  阅读(245)  评论(0编辑  收藏  举报