?給定一組數(shù)據(jù),每個(gè)數(shù)據(jù)都有一定權(quán)重,請(qǐng)寫(xiě)算法計(jì)算中位數(shù)數(shù)值[1.2,1.1,1.8,1.35,1.2,1.4,1.1]權(quán)重[1.2,2.1,1.4,2.13,2.1,0.5,1.2]?(String[]?args)?{
????[]?arr1?=?{}[]?arr2?=?{}[]?res?=?[arr1.](i?=?i?<?arr1.i++)?{
????????res[i]?=?arr1[i]?*?arr2[i]}
????Arrays.(res)Arrays.(res).forEach(System.::println)len?=?res.(len?%?!=?)?{
????????System..println(+?res[len?/?])}?{
????????midL?=?res[len?/?-?]midR?=?res[len?/?]System..println(+?(midL?+?midR)?/?)}
}麻煩幫我看看這樣寫(xiě)對(duì)不對(duì)
添加回答
舉報(bào)
0/150
提交
取消