Created
December 23, 2011 16:37
-
-
Save ainame/1514692 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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