Newer
Older
Ruby / hairetu.rb
@c123147 c123147 on 19 Dec 2024 345 bytes 2024-12-19 20:31:42
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

hairetu = ["1", "2", "3", "4"]
tokuten = 0
i = 0

while i < hairetu.length
  printf("%s yes or no\n", hairetu[i])
  x = gets.chomp

  if x == "yes"
    tokuten += 1
    i += 1
  elsif x == "no"
    i += 1
  else
    printf("yes or no\n")
    redo
  end
end

printf("今日は%d点です\n", tokuten)