i have difficulty understanding the logic especially in this part
for(int i=0;i<size;++i)
distrib[numbers[i]] +=1;
can someone please give a clear understaning of this ,i been thinking about it for some time now and still i can't understand
thanks
Well, numbers is an array of random numbers.
numbers[i] is element number i in the list (a random number). Using i means that every number in numbers is used once.
distrib[numbers[i]] means the numbers[i]th element in distrib.
+= 1 means increase by one.
distrib[0] is how many times 0 appears in numbers
distrib[1] is how many times 1 appears in numbers
distrib[x] is how many times x appears in numbers
So, the loop iterates through numbers (by using i) and increases the tally of how many times each number has appeared with +=1