- (void) viewdidload{intArray[] = {0,1,1,2,3,4,5,6,6,6,7,7,7,7,7,7,9,9,9,9,9}; Search (Array,sizeof(array)/sizeof(*array));}
voidSearchintA[],intLen) { intI, index,//Temp array subscript, a value corresponding to array i. Max =0;//The value of the temp corresponding to the position, both occurrences. inttemp[ +] = {0};//defines an array of 1000 elements with the initial value set to 0 for(i =0; i < Len; i++) {Index=A[i]; Temp[index]++;//which element appears most, resulting in temp[index] value Max } for(i =0; I < +; i++)//traverse the entire array to find the element with the largest value { if(Max <Temp[i]) {Max=Temp[i]; } } for(i =0; I < +; i++)//traverses the entire array, with the value of the bottom of the largest element of the output value plus 1 { if(max = =Temp[i]) {printf ("%d\n", i);//that is, the most frequently occurring element } }}
Gets the highest number of occurrences in the array