#include <string.h>
#include <iostream>
#include <map>
#include <utility>
using namespace std;
int main()
{
map<int, string> Employees;
// 1) Assignment using array index notation
Employees[101] = “Nikita”;
Employees[105] = “John”;
Employees[103] = “Dolly”;
Employees[104] = “Deep”;
Employees[102] = “Aman”;
Employees[106] = “Robot”;
Employees[107] = “William”;
cout << “Employees[104]=” << Employees[104] << endl << endl;
cout << “Map size: ” << Employees.size() << endl;
cout << endl << “Natural Order:” << endl;
for( map<int,string>::iterator ii=Employees.begin(); ii!=Employees.end(); ++ii)
{
cout << (*ii).first << “: ” << (*ii).second << endl;
}
cout << endl << “Reverse Order:” << endl;
for( map<int,string>::reverse_iterator ii=Employees.rbegin(); ii!=Employees.rend(); ++ii)
{
cout << (*ii).first << “: ” << (*ii).second << endl;
}
map<int, string> Users;
//Users
Users[101] = “Nikita”;
Users[105] = “John”;
Users[103] = “Dolly”;
Users[104] = “Deep”;
Users[102] = “Aman”;
Users[106] = “Robot”;
Users[107] = “William”;
Users[108] = “Unknown”;
cout << “Users[104]=” << Users[104] << endl << endl;
cout << “Map size: ” << Users.size() << endl;
cout << endl << “Natural Order:” << endl;
for( map<int,string>::iterator ii=Users.begin(); ii!=Users.end(); ++ii)
{
cout << (*ii).first << “: ” << (*ii).second << endl;
}
cout << endl << “Reverse Order:” << endl;
for( map<int,string>::reverse_iterator ii=Users.rbegin(); ii!=Users.rend(); ++ii)
{
cout << (*ii).first << “: ” << (*ii).second << endl;
}
}
喜欢历史的,请关注我的签约专栏《历史掌故》。
我也看不懂啊
牛逼克拉斯
。。。
是不是开源开的太快了。。。