#include < map >
#include < iostream >
using namespace std;
int main()
{
map < string , int > m;
m["abc"]=90;
m["abcd"]=80;
m["book"]=95;
m["books"]=90;
m["xyz"]=100;
m.erase("books");//删除books
/*
map < string , int > :: iterator it;
for(it=m.begin(); it!=m.end(); it++)
{
cout << (*it).first << ":" << (*it).second<< endl;
}
*/
//反向遍历
map < string , int > :: reverse_iterator rit;
for(rit=m.rbegin(); rit!=m.rend(); rit++)
{
cout << (*rit).first << ":" << (*rit).second<< endl;
}
cout << endl;
//判断是否有abc
if( m.find("abc") != m.end() )
cout << "abc" << ":" << m["abc"] << endl;
else
cout << "no";
cout << endl;
getchar();
getchar();
return 0;
}
|