def 密度(物) k = 0 j=0 for fruit in 物 k += fruit[1] j += fruit[1]*fruit[0] end j=j/k return j end puts 密度([[0.1,100],[0.4,100],[0.1,100],])
To embed this project on your website, copy the following code and paste it into your website's HTML: