Skip to content

Instantly share code, notes, and snippets.

@johobemax
Created December 1, 2010 03:36
Show Gist options
  • Save johobemax/722891 to your computer and use it in GitHub Desktop.
Save johobemax/722891 to your computer and use it in GitHub Desktop.
shiken.rb
class Gengo
attr_accessor :eng, :jap
end
shiken = Array.new(50){ Gengo.new }
#プログラム開始
i = 0
print "英=>"
ei = gets.to_i # 英語入力
while i < 50 and ei != 999
shiken[i].eng = ei
print "国=>"
jp = gets.to_i # 国語入力
shiken[i].jap = jp
i += 1
print "英=>"
ei = gets.to_i # 英語入力
end
n = i
#集計処理
sume = 0
sumj = 0
i = 0
while i < n
sume += shiken[i].eng
sumj += shiken[i].jap
i += 1
end
puts "英計=#{sume}"
puts "国計=#{sumj}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment