#include <iostream> #include <map> using namespace std; int main(){ map<int,int> m; for (int i = 0; i < 10; i++){ m[i] = i*i; } map<int,int>::iterator iter; iter = m.begin(); while(iter != m.end()){ cout << iter->first << "-" << iter->second << endl; iter++; } for (iter = m.begin();iter != m.end(); iter++){ cout << iter->first << "-" << iter->second << endl; } for(auto &it : m){ cout << it.first << "-" << it.second <<endl; } return 0; }
转载于:https://www.cnblogs.com/silentteller/p/10184641.html
最后
以上就是乐观星星最近收集整理的关于C++ map 遍历的全部内容,更多相关C++内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复