"Look,this is a pre-trial detention, the ethiopian criminal code clearly defines the conditions made by detaining authorities when a person is detained before trial.
VOA: standard.2009.05.25
Right. If you look at the rest of that code, gee, it looks a lot like what I had elsewhere.
好了如果你看看剩下的代码,天呐,看上去就像我在别的地方写过的。
You should acquire overtime this instinctive aversion to just code or programs that just look ugly because things that look ugly generally are not easy to maintain.
对于代码和程序你会有一种本能的讨厌,这是因为这些代码和程序看起来很丑陋,并且不容易维护。
And I want to spend a couple of minutes again reinforcing that. So if we look at that code and we were little more careful about this, what did we say to do? We said look an sorry.
内容了,我还要花几分钟,来强化下,所以,如果我们再仔细些看下代码,我们应该关注些什么?
The only thing that compiler needs to know is kind of what pattern to look for in the rest of your code.
编译器需要知道的唯一的东西是,用来在剩下的代码中寻找的函数形式。
Well, you won't be surprised to hear it's the same solution. So let's look at that code.
好了,听到二者是一样你可别惊讶,让我们看看代码。
OK, what I would like you to see is I've been printing out, as I went along, actually let's back up slightly and look at the code. There's merge sort.
好的,我想让你们看就是我运行过后,打印出来的结果,我们再回头看一下这段代码,这就是归并排序,输入一个列表。
Well, if we look back at the code here, take a look at what we're really doing.
好的,如果我们回过头来看代码,看看我们到底做了什么。
People make really stupid decisions and so as you know in this course with P sets there are three axes that we look at when evaluating your code.
人们做了一个愚蠢的决定,在这个课程上,通过习题集,当执行你的代码的时候,有三个评估方面。
Well just to see what we know what we're doing, let's look at this code here.
我们下一步该去怎么做呢?,好,让我们来看看。
And of course, you know, when you look at code it doesn't pause in between them.
当然,你们知道的,在代码执行的时候不会暂停。
- Writing code that just looks-- I'm not even sure what this is supposed to look like, a little flower or pinwheel or something like that.
这代码写出来有点像-,我不确定这像什么,像朵花,或纸风车,或其他什么东西。
OK, let me comment this out, and let's look at this next little piece of code. All right.
好,让我添加一点注释,然后让我们看看,下面的一些代码,好。
Because there will not be time to look at that code for the first time during the quiz, and figure out what it's doing.
因为在考试中,是没有时间去第一次看代码,并弄懂它的意思的。
At least you maybe finding that and if not when you look back at the code you then have written you'll realize that in fact it just requires a few lines of code.
至少你会发现这一点,不然的话,在你写完代码,返回去,看的时候你会意识到,实际上它只需要几行代码。
Let's run merge sort on it, and then we'll look at the code.
让我们在这个列表上运行归并排序,然后我们在看一下代码。
Let's look at the code.
让我们看程序。
OK. So if I look at this code, first of all I'm calling search, it just has one call, so looks like search is constant, except I don't know what happens inside of b search. So I've got to look at b search.
首先调用一下搜索,就一步调用,看起来搜索是固定的,除非我不知道二分搜索的原理,那我们来看看二分搜索吧,所以让我们看看,第一行打印出来的内容。
Well let's look at the next piece of code.
我们来看看下一段代码。
So let's look at this code for a second.
那么让我们来看看这个代码吧。
So let's look at the second example, all right, I keep doing that -- this piece of code from here to here gives me a way of now creating a hash table of size 256.
所以让我们来看一下第二个例子,好的,我继续做那件事,这段代码中从这里到这里,是创建一个大小为256的哈希表。
All right, so let's look at the code for that.
好,让我们看看代码。
OK? And in fact, if you look at the code up here, and it's on your handout, the very first one, x 1, right here- if I could ask you to look at it-- is a piece of code to do it. And I'm less interested in the code than how we're going to analyze it, but let's look at it for a second.
实际上,如果你看看,你们课堂发的材料上面的代码,第一页上的,就是那-,大家请看看实现的这一部分代码,我不太关心,我们会怎么解释这个代码,首先让我们先看看。
Well, let's look at the code. Right?
好,让我们先看看代码好不好?
Meaning, I'm just going to write a little loop that does that. All right, so let's go back to our code. That's right, let me pull this over a little bit, so I can see it. And what I'd like you to look at, I'm going to highlight it just for a second here, is those two pieces of code.
意思就是我只需,写一个小循环就可以了,让我们回到代码,让我们向下拉一点,我才看得见,我希望你看看这里。
It takes an int; deal with it when you get to it and then once you look through the whole file, should you find -- ultimately find the actual code that defines or impliments this thing.
它携带一个int数,当你获得了它就处理它,然后一旦你查看整个文件,最终你将发现实际代码中,定义或执行了这个东西。
And that shows you one other nice little thing we want to do, which is if I look in this code notice I set up a variable up here called false Solution Found, initially bound to false.
这显示了我们想要做的另一件事,那就是我在这段代码中设置了一个,名为Solution,Found的变量,初始值设为。
I can either look at my flow chart, or I can look at the code. If I look at the flow chart, it says, I'm at this point. Look at ANS squared. Is it less than or equal to-- sorry, first of all, 0 ANS squared is 0, is it less than or equal to x, yes.
我可以看流程图也可以看我的代码,如果我看流程图的话,流程图这么说的,在这一点,看看ANS的平方,看是不是小于等于-对不起,首先,ANS的平方是。
But let's look a little more carefully at the code for binary search-- for search 1.
二分搜索算法的代码,那么search,1,这个方法的。
So my challenge to you, and I know Professor Guttag can do this, my challenge to you is, a year from now, come back and look at code you wrote here.
因此我这里有个具有挑战性的任务,我知道Guttag也可能会说这个任务,我的这个任务就是,一年以后,回头来看,你之前写过的代码。
应用推荐