C++ map遍历code•2022-5-6•C•阅读34C++ map遍历 #include #include using namespace std; int main() { map _map; _map[0] = 1; _map[1] = 2; _map[10] = 10; map::iterator iter; iter = _map.begin(); while(iter != _map.end()) { cout << iter->first << " : " << iter->second << endl; iter++; } // 也可以使用for循环遍历 /* for(iter = _map.begin(); iter != _map.end(); iter++) { cout << iter->first << " : " << iter->second << endl; } */ return 0; } 程序的运行结果为: 注意: 如果使用for循环遍历map,不能写成 ‘<’ 的形式 欢迎分享,转载请注明来源:内存溢出原文地址:https://54852.com/langs/797510.html赞 (0)打赏 微信扫一扫 支付宝扫一扫 code管理员组00 生成海报 C语言概述上一篇 2022-05-06对Linux下使用C++读写word文件的技术方案比较 下一篇2022-05-06 发表评论 请登录后评论... 登录后才能评论 提交评论列表(0条)
评论列表(0条)