<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>zhiaihh (kids)</title>
    <link>https://ruby-china.org/zhiaihh</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>大神啊，为什么调用两次 ruby 函数，结果会互相干扰？？</title>
      <description>&lt;p&gt;$sz1 = [["&lt;em&gt;"], ["&lt;/em&gt;"], ["1", "7"]],[["&lt;em&gt;"], ["&lt;/em&gt;"], ["4", "2"]],[["3"], ["&lt;em&gt;"], ["&lt;/em&gt;"]],[["&lt;em&gt;"], ["&lt;/em&gt;"], ["6"]],[["&lt;em&gt;"], ["5"], ["&lt;/em&gt;"]],[["&lt;em&gt;"], ["&lt;/em&gt;"], ["6"]],[["&lt;em&gt;"], ["&lt;/em&gt;"], ["1", "7"]],[["8"], ["&lt;em&gt;"], ["&lt;/em&gt;"]],[["&lt;em&gt;"], ["9"], ["&lt;/em&gt;"]],[["&lt;em&gt;"], ["10"], ["&lt;/em&gt;"]],[["&lt;em&gt;"], ["&lt;/em&gt;"], ["*"]]
i=0&lt;/p&gt;

&lt;p&gt;while i&amp;lt;$sz1.size do
    p $sz1[i]
    i = i + 1
end
puts &lt;/p&gt;

&lt;p&gt;def read(p,temp1,temp5)
    temp1.push(p.to_s)#进队列
    while !temp1.empty? do
        t=temp1.shift#.shift出队列
        if !temp5.include?(t)&amp;amp;&amp;amp; t!="*"
            temp1=temp1+ $sz1[t.to_i][2]  #合并数组，即进队列
            temp5.push(t) #单个数据进队列
        end
    end
    return temp5.sort #.uniq 去掉重复元素
end&lt;/p&gt;

&lt;p&gt;def read2(p,temp2,temp3,temp4)
    #先把能得到的起始点找出
    while !temp2.empty? do
        t=temp2.shift #.shift 出队列&lt;/p&gt;

&lt;p&gt;if $sz1[t.to_i][p][0]!="*" 
            temp3.push($sz1[t.to_i][p][0]) #进队列
        end
    end&lt;/p&gt;

&lt;p&gt;while !temp3.empty? do
        t=temp3.shift#.shift出队列
        if !temp4.include?(t)&amp;amp;&amp;amp; t!="*"
            temp3=temp3+ $sz1[t.to_i][2]  #合并数组，即进队列
            temp4.push(t) #单个数据进队列
        end
    end
    return temp4.sort
end&lt;/p&gt;

&lt;p&gt;#初始化数组
temp1=Array.new #接下来要读的数，队列
temp2=Array.new #已经读过的数
temp3=Array.new #已经读过的数
temp4=Array.new #已经读过的数
temp5=Array.new #已经读过的数&lt;/p&gt;

&lt;p&gt;temp2=read 0,temp1,temp5
p temp2
p read2 1,temp2,temp3,temp4
temp2=read 0,temp1,temp5
p temp2
p read2 0,temp2,temp3,temp4&lt;/p&gt;</description>
      <author>zhiaihh</author>
      <pubDate>Wed, 02 Apr 2014 21:05:44 +0800</pubDate>
      <link>https://ruby-china.org/topics/18351</link>
      <guid>https://ruby-china.org/topics/18351</guid>
    </item>
  </channel>
</rss>
