You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
782 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<bits/stdc++.h>
using namespace std;
/*
知识点内容STL map详解
Map是STL的一个关联容器它提供一对一其中第一个可以称为关键字每个关键字只能在map中出现一次第二个可能称为该关键字的值的数据处理能力
由于这个特性,它完成有可能在我们处理一对一数据的时候,在编程上提供快速通道。
文档内容参考:
https://www.cnblogs.com/aiguona/p/7231451.html
* */
int main() {
map<char, int> a;//定义map函数
a.insert(map<char, int>::value_type('c', 1));//插入元素
a.insert(map<char, int>::value_type('d', 2));
map<char, int>::iterator b = a.find('c');//查找元素
map<char, int>::const_iterator it;
for (it = a.begin(); it != a.end(); ++it)
cout << it->first << "=" << it->second << endl;
cout << endl;
a.clear();//删除所有元素
return 0;
}