0
两个样本阵列:字符串数组使用令牌分析C++
string key[] = {"a|b", "a|c","a|d","b|c","b|d"};
int value[]={"2", "3","4","5","2"};
并且这两个阵列是结缔组织<a|b>->2 <a|c>->3 <a|d>->4 <b|c>->5 <b|d>->2
通过"|"
此令牌用于front_element和sencond_element
例如分离每个键: a|b
a is front_element b is second_element
阵列可能是一个非常大的数组,我想找到一种方法或算法 ,可以快速搜索元素
if(front_elemnet = "a"){ // find all of the front element with "a"
value_plus(); //plus the value 2+3+4
}
然后查了下不同的前元素
if(front_elemnet = "b"){ // find all of the front element with "b"
value_plus(); //plus the value 5+2
}
我有n o想出你的问题是什么。请参阅[我如何提出一个好问题?](http://stackoverflow.com/help/how-to-ask) –
您可以更改数据的存储方式吗?将数据添加到数组时,您可以为每个字母保留一个计数吗?还是提供完整的?钥匙总是一封信吗? –
你是否需要*使用数组?你不能使用例如地图? –