-
-
Save anonymous/fc859ee262cf17b05f63f85ec2866692 to your computer and use it in GitHub Desktop.
This file contains 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
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