The reason I'm going to show you this flow chart, I'm going to do one other example in a second, but I want to show you a comparison.
我稍后还会给大家讲另外一个例子,我给大家看这个流程图的原因,是我想给大家一个对比。
So here's a simple flow chart that I'm going to use to capture what I just described.
就和我刚才描述的一样的流程图,然后我会,再说一次,我实际上和他们原来。
Despite making a bad joke about it we're going to do the same thing here.
尽管关于流程图我说了个很糟糕的笑话,我们还是要去画流程图。
We're going to do the same thing here, we're going to chart out a little bit of what should go into actually making this thing work.
我们要去画一个小小的流程图,来指导问题的解决,那么这里是一个很简单的。
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的平方是。
OK, so how can I code this up? Well, you might think, let's just jump in and write some code, I don't want to quite do that though, because I want to show you another tool that's valuable for thinking about how to structure the code, and that is a something called a flow chart. Now.
好,那么我怎么把这个以代码实现呢,你可能会想,让我们进去直接写代码把,但是我不想这么做,因为我想教给大家另外一项很有价值的,用来组织代码的工具,叫做流程图,现在,像Guttag教授,和我这么大岁数的人。
I test an end test. So the flow chart says, and the tradition was to do this in a diamond shape, I'm going to check if ANS times ANS-- oh, which way did I want to do this x - is less than or equal to x. Now that's a test.
首先进行终结测试,因此流程图就的去,传统的做法是把这个放到一个菱形里面,检查下是否ANS乘以ANS-哦,我刚才是怎么说的来着-是不是小于等于。
应用推荐