From: nobu.nokada@... Date: 2005-11-12T16:30:52+09:00 Subject: Re: I rea......lly need your help ( C++ ) Hi, At Sat, 12 Nov 2005 13:52:15 +0900, ashmangat@yahoo.com wrote in [ruby-talk:165395]: > Calculate and display the average, median, and mode of the values > entered. students = [] ARGF.each do |line| /^\d+$/ =~ line or break students << line.to_i end mode, = students.inject(Hash.new(0)) {|h, s| h[s] += 1; h}.max_by {|s, n| n} avrg = students.inject(0) {|a, s| a + s}.to_f / students.size require 'pp' print "The array is: " pp students puts "The Mode is #{mode}." puts "The average is #{avrg}." -- Nobu Nakada