I've decided that I need to be able, in my program, to swap the value of two variables. All right.
我觉定在我的程序中,我可以,交换两个变量值,好的。
I look at the rest of the list to decide what's the element to swap into the next place.
我会查看列表剩下的部分,来看看需要交换哪个元素。
So, a couple of weeks ago we proposed to swap two integers, and we couldn't at the time.
那么,几周前,我们提出交换两个整数,然而在那时,我们办不到。
I remember when interest rate swap accounting was done on a different market security basis.
我记得利率会换记账法,在不同的证券市场施行时。
And I'm going to hook you up to my machines and swap your minds.
我准备把你们绑在机器上,交换意识。
Once each time. Right? I only do one swap potentially, it-- though not one potentially, each time at the end of the loop I do a swap.
每次循环做一次,对么?我其实,就可能做了一次交换,也许并不是可能,每次循环的结束我都得做一次交换。
You actually need to kind of do this and then you can swap these two numbers but it requires 50 percent more memory.
你实际上需要这样做,然后才能交换两个数字,但是它需要多50%的内存。
They only need to have values if you care GetInt about getting something back from them, get int, swap you care about its value; but swap, I don't want to hear it again.
它们只需要拥有值,如果你关心,它们的返回值,你关心它的返回值,但是,我不想再得到它的返回。
I then insist, okay, swap, and then I print out their values again.
我再强调,好的,交换好了,然后我再打印出,它们的值。
In the second case, I found in the next smallest element and moved here, taking what was there and moving it on, in this case I would swap the 4 and the 8, and in next case I wouldn't have to do anything.
在第二次遍历中,我找到了,第二小的元素,把它移到这里,把这里原来的元素移到哪里,在这一次遍历中,我会把8和4交换,然后一次遍历,不会做任何事情。
swap I'm going to keep track of a little variable called swap, it's initially true, and as long as it's true, I'm going to keep going, but inside of the loop I'm going to set it to false, and only if I do a swap will I set it to true.
我打算跟踪一个小的变量称为,初始值为真,只要它是真的,算法就会继续,但是在循环里,我打算把他设为假,除非交换发生,就把它设为真。
Just swap these two values for me and let me move on is the reasoning.
只要帮我把这两个值交换,让我继续往下执行。
So when I said earlier that as soon as swap returns, all of the memory allocated for swap is now useless.
我前面指明的,一旦swap返回,所有为swap分配的内存都是无用的了。
But the moment swap returns, the moment we hit this bottom most curly brace, what conceptually happens in memory?
但是swap返回时,当我们抵达花括号底端是,在内存中发生了什么?
I'm simply saying swap X with Y, but this 2 won't work, because where are X and Y defined?
我只简单地说交换X和Y,但是这两行不起作用,因为X和Y是在哪里定义的呢?
And what happens the moment I call swap, as I said earlier, you get a copy of the inputs.
当我调用swap时会发生什么,之前说过的,你得到一个输入。
So, in this program when we call this version of swap 1 and 2 do not end up here, right?
所以,在这个程序中,当我们调用这个swap版本1,和版本2,不是在这里结束,对不?
I then perform the swap.
然后执行交换。
应用推荐