该问题还是比较容易解答的。具体代码如下
NUM:=[2,3,4,6,5,6,3,12,45,6,2,32,3,4,2,2,4,5,6,6]
tuple_sort (NUM, Sorted)
tuple_uniq (Sorted, Uniq)
ElementValue:=[]
Times:=[]
for Index := 0 to |Uniq|-1 by 1
tuple_find (NUM, [Uniq[Index]], Indices)
tuple_length (Indices, Length)
*将出现的元素和次数放在对应数组
ElementValue:=[ElementValue,Uniq[Index]]
Times:=[Times,Length]
endfor
*统计数组元素出现的最大次数
tuple_max (Times, Max)
*该最大次数的对应数组元素
tuple_find (Times, Max, Indices1)
MaxElement:=ElementValue[Indices1]
|