新手问题 Ural 1000 A+B 百思不得其解 [solved]

qiukun · 2013年06月10日 · 最后由 qiukun 回复于 2013年06月10日 · 2390 次阅读

http://acm.timus.ru/problem.aspx?space=1&num=1000

puts gets.spilt(" ").map {|x| x.to_i}.inject :+

居然。。错了。。

。。我 2 了,打错字了 puts gets.split(" ").map {|x| x.to_i}.inject :+

NoMethodError: undefined method `spilt' for "1 5\n":String

#1 楼 @themorecolor

a, b = gets.split(" ").map {|x| x.to_i}
puts (a + b) 

这是对的

#3 楼 @qiukun 你上面单词拼写错了啊

#2 楼 @themorecolor 擦,复制来复制去错了··

#3 楼 @qiukun puts gets.split(" ").map {|x| x.to_i}.inject(:+)加上括号就没有问题了

#6 楼 @themorecolor 不不,就是我打错了。。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号