#include<map>
#include<iostream>
using namespace std;
char maxCount(const char*);
void main()
{
char buff[200];
cout<<"Please input string:"<<endl;
cin>>buff;
cout<<"The max count char in buff is:"<<maxCount(buff)<<endl;
}
char maxCount(const char * string)
{
]map<char,int> c_map;
const char *p=string;
while(*p)
{
c_map[*p]++;
p++;
}
int max=0;
map<char,int>::iterator it=c_map.begin();
char find=it->first;
for(;it!=c_map.end();it++){
if(max<it->second)
{
max=it->second;
find=it->first;
}
}
return find;
}
stl map高效遍历删除的方法:
for(;iter!=mapStudent.end();)
{
if((iter->second)>=aa)
{
//满足删除条件,删除当前结点,并指向下面一个结点
mapStudent.erase(iter++);
}
else
{
//条件不满足,指向下面一个结点
iter++;
}
}
分享到:
相关推荐
java,利用keySet进行遍历map
博文《Java中如何遍历map》源码。可以直接粘贴博文中源码 也可以下载它,免费了。
数据模型: @RequestMapping(/freemarker) @Controller public class FreemarkerController { //测试1 @RequestMapping(/test1) public String test1(Model model){ //向数据模型放数据 model.addAttribute(name...
遍历MAP的几种方法,利用keyset进行遍历,它的优点在于可以根据你所想要的key值得到你想要的 values,更具灵活性
map遍历的三种方法map遍历的三种方法map遍历的三种方法
详细介绍啦遍历map的几种方式,好吧,共有四种方式
java Map 遍历方法 Map map = new HashMap(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) {
你知道map的遍历方法有几种吗? 那这几种的区别是什么呢? 那种更简单、高效呢? 我的资源文件将告诉你。
js遍历map javaScript遍历map的简单实现 var map = { "name" : "华仔", "realname":"刘德华" }; for (var key in map) { console.log("map["+key+"]"+map[key]); } 这样会把map给遍历掉,显示在浏览器上的...
vue中循环遍历使用的指令是v-for 1.v-for遍历数组 (1)value in arr 遍历数组中的元素 (2)(value,index) in arr 遍历数组中的元素和数组下标 运行代码: <body> <li v-for=value>{{value}}</li><br> ...
另一种遍历Map的方式,讲述如何使用java中的map
C++11 unordered_map与map(插入,遍历,Find)效率对比。
JAVA遍历Map所有元素.docaaaaaaaaaaa
这是一人篇关于JAVA MAP遍历的讲解的文章,希望对你有用
Map的遍历大体有3种: 1、遍历Map.entrySet():它的每一个元素都是Map.Entry对象,这个对象中, 放着的就是Map中的某一对key-value; 2、遍历Map.keySet():它是Map中key值的集合,我们可以通过遍历这个集合来 ...
主要提供java中的map的遍历实例及效率比较
js中遍历Map对象的方法 console.log(jsonData);//火狐控制台打印输出: Object { fileNumber="文件编号", fileName="文件名称"} for(var key in jsonData) console.log("属性:" + key + ",值:"+ jsonData[key]);...
Map集合的最常规的遍历方法
js中使用map形式存取遍历
长版本:从有效的工作空间配置对象中读取workspaces属性,并遍历在其中定义的路径和glob,以查找有效的嵌套程序包,并返回所有找到的程序包的Map ,其中键是程序包名称,值是文件夹位置。 安装 npm install map-...