Hi, I've come across a problem where i seem to be doing the counting of numbers in a inefficient way i've got a 200x200 array with numbers ranging from 101-600 and also 0 and 1. and i need to count the number of times each number appears in the array. only thing i could think of was this but its quite long.
if (s[i][j]==101) {count_c101 ++;}
if (s[i][j]==102) {count_c102 ++;}
if (s[i][j]==103) {count_c103 ++;}
if (s[i][j]==104) {count_c104 ++;}
if (s[i][j]==105) {count_c105 ++;}
if (s[i][j]==106) {count_c106 ++;}
if (s[i][j]==107) {count_c107 ++;}
if (s[i][j]==108) {count_c108 ++;}
if (s[i][j]==109) {count_c109 ++;}
if (s[i][j]==110) {count_c110 ++;}
if (s[i][j]==111) {count_c111 ++;}
if (s[i][j]==112) {count_c112 ++;}
if (s[i][j]==113) {count_c113 ++;}
if (s[i][j]==114) {count_c114 ++;}
if (s[i][j]==115) {count_c115 ++;}
if (s[i][j]==116) {count_c116 ++;}
if (s[i][j]==117) {count_c117 ++;}
if (s[i][j]==118) {count_c118 ++;}
if (s[i][j]==119) {count_c119 ++;}
if (s[i][j]==120) {count_c120 ++;}
if (s[i][j]==121) {count_c121 ++;}
if (s[i][j]==122) {count_c122 ++;}
if (s[i][j]==123) {count_c123 ++;}
if (s[i][j]==124) {count_c124 ++;}
if (s[i][j]==125) {count_c125 ++;}
if (s[i][j]==126) {count_c126 ++;}
if (s[i][j]==127) {count_c127 ++;}
if (s[i][j]==128) {count_c128 ++;}
if (s[i][j]==129) {count_c129 ++;}
if (s[i][j]==130) {count_c130 ++;}
....
....
....
this is a small part of my entire code, where i use all the different values of count_c101,count_c102,count_c103,count_c104,count_ c105,.....
I would be grateful for any help
kind regards,
Kam