-1
我正在考慮數組的數目,並且我想使用&
運算符來計算數組中的缺陷,但在我的情況下,在計算交集之後str1 & str
在str1
數組中,但str1
爲空。使用&運算符計算數組的缺失
n = gets.strip.to_i
str1 = Array.new
str2 = Array.new
for i in 0..n-1 do
str = gets.strip.split("").map { |s| s.to_s }
if i < 1
str1 << str
#puts str1.kind_of?(Array)
#puts str.kind_of?(Array)
else
#puts str1
#puts "no"
#puts str
str1 = str1 & str
puts str1
end
end
puts str1.length
你正在編寫程序,以找出哪些字符出現在_all_輸入的字符串,對不對?你爲什麼不這麼說? –
嗨,使用此鏈接imporve你的問題:http://stackoverflow.com/help/how-to-ask –