以下是引用csyx在2023-3-13 14:56:09的发言:
Create Cursor test ( ;
a1 V(10),a2 V(10),a3 V(10),a4 V(10),a5 V(10),a6 V(10),a7 V(10),a8 V(10) ;
,rate Y,maxa V(10))
Insert into test (a1,a2,a3,a4,a5,a6,a7,a8) values ( ;
"七仙女","黄大仙","黄大仙","黄大仙","黄小仙","黄大仙","黄大仙","王母娘娘")
Insert into test (a1,a2,a3,a4,a5,a6,a7,a8) values ( ;
"七仙女","黄大仙","七仙女","黄大仙","七仙女","七仙女","黄小仙","王母娘娘")
Insert into test (a1,a2,a3,a4,a5,a6,a7,a8) values ( ;
"黄小仙","黄大仙","黄小仙","黄大仙","黄小仙","七仙女","黄小仙","王母娘娘")
Insert into test (a1,a2,a3,a4,a5,a6,a7,a8) values ( ;
"王母娘娘","王母娘娘","黄大仙","黄大仙","黄小仙","王母娘娘","王母娘娘","王母娘娘")
Select test
Scan all
Release aaa,bbb
nn = Recno()
Copy To array aaa fields like 'a?' RECORD nn
Dimension aaa[Alen(aaa,2),1]
Create Cursor temp (ax V(10))
Append From array aaa
Select ax, Count(*) from temp group by ax order by 2 desc into array bbb
Use in temp
Select test
Replace next 1 maxa with bbb[1,1], rate with bbb[1,2] / Alen(aaa,1)
EndScan
Browse
这个算法非常简洁!
远比我写的那一大堆啰哩啰嗦的8次机械比较算法,简洁了不知多少倍!
就是有些艰涩,我得逐句逐句好好消化一下子。