有没有一种方法如何确定等于字符的计数阵列的细胞在C ++? [英] Is there a way how to determine count of equal char in cell of array in c++?

查看:124
本文介绍了有没有一种方法如何确定等于字符的计数阵列的细胞在C ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最好的方式就是你怎么能确定的单元阵列的平等的字符计数 C ++

What are the best way's how can you determine count of equal characters in cell of array in c++ ?

我们有二维阵列具有两列: abcda1s aba2cccc

We have two-dimensional array with two columns: abcda1s aba2cccc

和我需要获得最高数量相等的字符由这两种细胞,显然在这里,性格'C'和它的使用5次。

and I need to get the highest number of equal characters from both of these cells, obviously here it,s character 'c' and its used five times .

因此​​,这里我的问题是确定所使用的大部分的字符,和次数它被使用的次数。

So my problem here is to determine the character which is used the most, and the number of times it is used.

推荐答案

您可以使用的HashMap<焦炭,无符号整型> MYMAP 去一次通过你的二维数组,做每一个字符:

You could use a HashMap<char, unsigned int> myMap and go one time through your two dimensional array and do for every char:

myMap['C'] += 1;

,其中C是你目前的字符。

where 'C' is your current char.

之后,你通过你的地图和搜索具有最高INT的字符。

After that you go through your map and search for the char with the highest int.

如果您不知道的HashMap的,看看这里

If you don't know HashMap's, look here.

这篇关于有没有一种方法如何确定等于字符的计数阵列的细胞在C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆