相对简单的一道题。考察stl 中 map的应用
#include <iostream>
#include <map>
using namespace std;
map<string, int> h;
int n;
int main()
{
cin >> n;
while(n -- )
{
int op;
cin >> op;
if(op != 4)
{
string str;
cin >> str;
if(op == 1)
{
int s;
cin >> s;
h[str] = s;
cout << "OK" << endl;
}
else if(op == 2)
{
if(h.find(str) == h.end())
cout << "Not found" << endl;
else
cout << h[str] << endl;
}
else if(op == 3)
{
if(h.find(str) != h.end())
{
cout << "Deleted successfully" << endl;
h.erase(str);
}
else
{
cout << "Not found" << endl;
}
}
}
else
{
cout << h.size() << endl;
}
}
return 0;
}