-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 –