清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
puts "Enter Number Of Classes" n=gets.chomp n=n.to_i puts "Enter Class Interval" h=gets.chomp h=h.to_f sum_f=0 sum_fx=0 i=0 while i<n: i=i+1 puts "For class "+i.to_s puts "Enter lower limit" l=gets.chomp l=l.to_f u=l+h puts "Enter frequency" f=gets.chomp f=f.to_i x=(l+u)/2 fx=f*x sum_fx=sum_fx+fx sum_f=sum_f+f end mean=sum_fx/sum_f puts "The mean is "+mean.to_s