27 lines
467 B
C++
27 lines
467 B
C++
#include <iostream>
|
|
#include <map>
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
map<int, string> m;
|
|
m.insert(make_pair(1, "disen"));
|
|
m.insert(make_pair(2, "lucy"));
|
|
m.insert(make_pair(3, "jack"));
|
|
|
|
map<int, string>::const_iterator it = m.find(3);
|
|
|
|
if (it == m.end())
|
|
{
|
|
cout << "未查找到" << endl;
|
|
}
|
|
else
|
|
{
|
|
const pair<int, string> &p = *it;
|
|
cout << p.first << ", " << p.second << endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|