Ruby Numeric Reference Program

For myself I made a simple numerical reference program. Code below


m = gets.chomp
n = gets.to_i

room = []

n.times do
  count = gets.chomp

a = 0
count = n

while n > 0

  if ! (room[a]).include?(m)
    puts room[a].to_i
    count -= 1
    if count == 0
      puts "none"
  n = n - 1
  a = a + 1

First, enter the reference source value in the variable m. (Although it is character data) Based on that, we input numerical values and output only the numerical values that do not apply.

If all are not true, "none" is returned.

This if statement is a case that "does not apply", so I made it in the form of if !. Also, I thought that the character string could be referred to more easily with include? In the flow that first refers to a character string and converts it to a numerical value at the time of output just made it.

Recommended Posts

Ruby Numeric Reference Program
Ruby payroll program
Ruby score calculation program
Use C program from Ruby
Ruby: I made a FizzBuzz program!
[Ruby] A program that determines prime numbers