And for reference, incidentally, in case you ever forget what the point of some exercise was, I'll almost always comment the code up top with a quick sentence or two that reminds you what this program does.
顺便作为参考,为了避免我们可能忘记一些代码的意思,我通常会用一两个简单的句子,在上面作出注释,那样会提醒我们这个程序是干嘛的。
So what you typically do and a hash case is you design your code to deal with that.
你所需要做的就是通过设计你的代码,来解决上面的问题。
In the case of last year we did hand students some code with which they could write programs that talked to Yahoo Finance, finance.yahoo.com, free website.
在去年的情况下,我们给学生提供一些,能用来写程序跟雅虎财经的免费网站交互的代码,即finance。yahoo。com,一个免费的网站。
And the code over here says, OK gee, if I'm in the base case do something.
如果我属于基础事件就进行一些操作,而我不是,所以往下看这儿。
Right? If that was the case in that code, then my complexity is no longer log, because I need linear access for each time I've got to go to the list, and it's going to Lisp be much worse than that.
这里的复杂度不再是对数的了,因为每次在列表中,查找需要线性访问,可能还要糟糕,其实,有些编程语言,如。
First one, when I write a piece of code, especially code that has branches in it, when I design test cases for that piece of code, I should try and have a specific test case for each possible path through the code.
第一点,当我们写代码的时候,尤其是一些含有分支语句的代码的时候,当我为这些代码,设计测试用例的时候,我应该为每一个可能的程序路径,都设计一个特别的用例。
So now, in this case, this code is going to, when we get here, check, and if you haven't seen that strange thing there, that exclamation point in bang computer-ese called a bang, it says x if ANS star ANS is not equal to x, all right?
那么现在,在这个例子中,当我们执行到这里,代码会去检查,如果你没有看到过这个奇怪的东西,这个感叹号在计算机学中被叫做,代码的意思是如果ANS的平方不等于?
SRC back One is called SRC for Source and one is called SRC.back which was my backup of today's source code in case I screw up.
其中一个叫SRC,用来装源代码,另一个叫,用来备份源代码,以防我搞砸了。
应用推荐