我想用数组中的键创建表。有没有一种简单的方法来做到这一点。使用特定值计算函数调用的次数
int array1[] = {1,5,3,8,9,11};
// table[1]
// table[5]
// table[3]
int count(int a)
{
//a is one of the values in array. array1[] = {1,5,3,8,9,11};
// for ex 3.
// I have to figure out how many times this function was called with what values 1/5/3/8/9/11
table[3]++;
}
创建一个全局数组(即在你的函数count()之外),将它设置为零(int)。如果遇到array1中的值,则增加indice值。 – aghoribaba 2014-10-16 18:35:06