清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
@score=[] @balance=[] sum=0 total_credit=0 puts "input your the number of your courses:" course_number=gets puts "inputs your scores now:" for i in 1..course_number.to_i temp=gets @score<<temp.to_i end puts "input your balance now:" for i in 1..course_number.to_i temp2=gets @balance<<temp2.to_i end for i in 1..course_number.to_i sum=sum+@score[i].to_i*@balance[i].to_i end for i in 1..course_number.to_i total_credit=total_credit+@balance[i].to_i end result=sum/total_credit puts "your balance average score is #{result}"