OK I have a 2dimensional array. I need to be able to search through the array and tell the user how many times each number appears in the array. My hack job code is as follows:
Code://this program counts the number of times A number occurs In an array #include <iostream.h> void main() { short numbers[5][3] = {{2, 3, 5}, {6, 3, 5}, {7, 2, 1}, {4, 5, 9}, {3, 5, 1}}; short tmpNum = 1; //Number being seeked will increase by 1 Until done short tmpCount[] = {0}; //Number of times it has been found (counter) short xCt = 0; for(tmpNum = 1; tmpNum <10; tmpNum = tmpNum +1) //Each Number //I need A way To look into the array For Each number from 1-9 //Display Results cout << "Number " << tmpNum << " appears " << tmpCount[xCt] << " times. " << endl; } //end of main Function 'Code improved by vBulletin Tool (Save as...)
Please Help, I'm way confused!




Mahalo
Reply With Quote