Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created April 23, 2017 03:05
Show Gist options
  • Save anonymous/fc859ee262cf17b05f63f85ec2866692 to your computer and use it in GitHub Desktop.
Save anonymous/fc859ee262cf17b05f63f85ec2866692 to your computer and use it in GitHub Desktop.
index = 0
numbers = Array.new
negatives = Array.new
positives = Array.new
puts "Enter a list of numbers here, one line at a time.\n When you are finished entering your numbers, either press ctrl+z and hit enter, or manually enter ^z and then hit the enter key."
while (number = gets)
numbers[index] = number
index += 1
end
for i in 1...numbers.length do
if numbers[i] > 0
positives.push(numbers[i])
else if numbers[i] < 0
negatives.push(numbers[i])
end
puts "Displaying positive numbers you have entered: \n"
puts positives
puts "\nDisplaying negative numbers you have entered: \n"
puts negatives
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment