Created
July 8, 2013 13:42
-
-
Save webcrafts/5948862 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 | |
te = ["","グー","チョキ","パー"] | |
report = [""] | |
3.times do |i| | |
# my_te = gets.to_i | |
my_te = rand(3)+1 | |
pc_te = rand(3)+1 | |
puts "人間の手は「#{te[my_te]}」、コンピュータの手は「#{te[pc_te]}」" | |
if my_te == pc_te then | |
kekka = "あいこ" | |
elsif (my_te == 1 && pc_te == 2) || (my_te == 2 && pc_te == 3) || (my_te == 3 && pc_te == 1) then | |
kekka = "人間の勝ち" | |
else | |
kekka = "コンピュータの勝ち" | |
end | |
puts "勝敗結果は・・・「#{kekka}」です。" | |
report[i] = kekka | |
end | |
puts "******************************************" | |
puts "対戦結果は・・・" | |
report.size.times do |i| | |
puts "#{i}回戦の結果は・・・#{report[i]}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment