Skip to content

Instantly share code, notes, and snippets.

@ainame
Created December 23, 2011 16:37
Show Gist options
  • Select an option

  • Save ainame/1514692 to your computer and use it in GitHub Desktop.

Select an option

Save ainame/1514692 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
def parse_max(data)
puts "要素数:" + data.size.to_s
max = 0
max_idx = 0
data.each_with_index do |val, idx|
val = val.to_f unless val.kind_of? String
if max <= val
max = val
max_idx = idx
end
end
puts "最大値:" + max.to_s
puts "最大値のインデックス:" + max_idx.to_s
end
array = Array.new
while line = $stdin.gets
if line =~ /Pred/
array << line.split[3].to_f
end
end
parse_max(array)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment