大侠进来看一下输出及排序的问题。
一本英文参考书上的一道题目,我就不翻译了。
Let's write a program which asks us to type in as many words as we want (one word per line, continuing until we just press Enter on an empty line), and which then repeats the words back to us in alphabetical order.
哪位大侠帮帮我啊,先谢了。
[解决办法]
#!/usr/bin/env ruby -wKU
a = []
while (gets!="\n") do a << $_.chomp end
puts a.sort.join(" ")
[解决办法]
a = []
while (gets!="\n") do a < < $_.chomp end
puts a.sort.join(" ")