擅长:python、mysql、java
<p>数组索引从0开始。这将导致您访问数组的最后一个元素。在</p>
<p>假设你有<code>a = [1,2,3,4]</code>,那么{<cd2>}是4。这个数组的最后一个元素是<code>a[3]</code>。这意味着从这条线来看:</p>
<pre><code> if (2*swap)<=len(a):
</code></pre>
<p>对于swap,您最多可以获得2的值,这意味着您实际上在做:</p>
^{pr2}$
<p>它是数组末尾的1。在</p>