linux:cpp学习:std_lib_study
std_lib_study
1. map
1.1 find
#include<stdio.h> #include<map> using namespace std; int main() { /* map.find(key)返回键为key的映射的迭代器 */ map<char, int> mp; mp['m'] = 20; mp['r'] = 30; mp['a'] = 40; map<char, int>::iterator it = mp.find('a'); if (it !=mp.end()){ printf("%c %d\n", it->first,it->second); // 只有map迭代器可以使用first/second方式 } else { printf("没找到\n"); } return 0; }
1.2 map用法
linux/cpp学习/std_lib_study.txt · 最后更改: 2023/03/17 10:12 由 127.0.0.1