So we can see what it's doing is it runs. So let's try fib it here with Fib of 6.
我们可以看到它在,运行的时候做了什么,让我们试试。
So in general, when you're running command line programs, they can take input or arguments or parameters or switches or flags.
一般而言,当你运行命令行程序时,可以把把这些当做输入,像什么参数啊,或开关啊,或标志啊等等。
All right. Then we're going to set low to-- low and high, and we're going to perform exactly the process I talked about.
不满足条件,我们就可以直接停止运行了,好,接下来我们要定义边界值,然后按照我之前。
Now,having said that,let me just say as an addendum -- and this is my opinion,you could ignore it-- that things work in France.
根据前面提到过的,再谈一点补充,这是我自己的看法,你们可以忽视,法国社会运行顺利
And now since it's reversible, we can run it forward or backward.
因为它是可逆的,所以可以正方向运行。
How many steps does it take for this function to run? Well, you can kind of look at it, right?
这个方法运行了多少补?,你可以看看代码?
OK, says it says enter a float. I give it something that can be converted into a float, it says fine. I'm going to go back and run it again though. If I run it again, it says enter a float.
好了,看到他说输入一个浮点数,我输入它可以转换为浮点数的值,那没问题,我回过来再运行一遍,如果我再运行一遍。
OK. Having done this now, I can simply go ahead and run this, and in fact if I go up here to run, you'll see I've got both an option to check the module, though in this case I'm just going to run it.
好,讲完了这些,我可以去执行程序了,实际上如果我在这里运行,你们会看到我同样得到了,一个可以同时检查模块的选项,虽然在这个例子中我就是直接去运行程序了。
- These ones should curl, see if I can - oh, not bad. Let's run it.
这些东西可以卷上去,让我们看看,结果不错,让我们来运行一下程序。
And if your program doesn't work, that should be your first guess.
如果你的程序无法运行的时候,它们可以成为你的第一猜测。
You could run through a little loop to say keep trying until you get one. But one of the ways I could deal with it is what's shown here.
你可以运行一个小循环来不断地做,直到得到一个输入,但你应该做的是弄明白这里到底要干什么。
Now, the things in green are special things that I ran.
其中绿色的文件是可以运行的。
Well, you could just try it and see if it works, right? That's what testing is all about.
你可以仅仅的去试试运行程序,然后看看结果对不对?这就是测试的内容。
Not just the one where it didn't work, but also the ones where it did.
因为可能程序对一些输入可以,正确运行但对另外一些却不能。
I can tell you the answer, but that's because I've cheated, run the program before.
我可以告诉你答案,但这是因为我作弊了,我之前运行过一次程序。
OK. All right, let me show you one other tool that I want to use. Which is, I've written that piece of code, I ought to check it. Well, I could just run it, but another useful thing to do is, I'm, especially as I want to debug these things, is to simulate that code.
好,那么,让我给大家讲下,我想用的另外一个工具吧,也就是,我已经写好了这一块代码,我应该去检查检查,那么我可以去运行它,但是特别是当我想要调试代码的时候。
Suppose instead, I want a machine that can take a recipe, the description of a sequence of steps, take that as its input, and then that machine will now act like what is described in that recipe.
假设换成这个,我想要一台可以安装描述,一系列步骤的结果的方法的机器,把那个当做输入设备,然后那台机器可以像方法中,描述的那样运行了。
GCC We start at this lower level with GCC.
我们可以在低平台上运行。
I could run it, it'll do the right thing.
我可以运行这个程序,程序没错。
Well, what I always do in anything like this is, the first thing I do is, I run it on something where I can actually compute the answer in my head. So I get a sense of whether or not I'm doing the right thing.
好的,我常常在,这种问题中会做的是,我会做的第一件事是我,会先带入我可以心算的值来运行,因此我能够知道我是否做对了。
You're doing work on the environment.
可以驱动汽车运行。
The format is the same. I'm going to ask for some input, and then I am going to use that procedure to check, is this the right type of value. And I'm trying to use that to do the coercion if you like. Same thing if it works, I'm going to skip that, if it not, it's going to throw the exception.
格式是一样的,我需要一些输入,然后我要用一个过程来检查,是否是正确的值,然后你就可以做强制转换了,如果能运行,那是一样的,我打算跳过这段,如果不正确,那就会抛出一个异常。
Imagine I have a little lamp, a little goose- one of those little gooseneck lamps, I'd put it on the table here, I'd put the height about a f-- about a foot off the table. And if I was really good, - I could hit, or time it so that when I hurt- yeah, try again. When I turn this on switch on in the lamp, at exactly the same time, I'm going to hit a key on my computer and start it running.
想象下我有一个那种小雁颈台灯-,我把它放在桌子上,大概离桌子,有一英尺那么高吧,这样挺好的,我可以打开-,或者关闭这灯,并在这同时,我可以让我电脑,开始运行。
It's a little more involved on a PC but it's all free, the software you can download, and Linux in similar operating systems generally come with a compiler or you run a simple command to get it.
在PC机上有点复杂,但是它是免费的,你一般下载的软件,类似Linux的操作系统等等通常都需要,一个编译器,或者你可以运行一些简单的指令来获取。
So pictorially, you can imagine foo getting called and then it finishes running; so these rows in this chart will just be whisked away.
看起来,你可以想象foo被调用,然后它结束运行,所以这个图表中的这些行,将被快速移去。
I spotted an error here, I could have spotted it by running it on different test sets, and using prints things, another way of doing it, but this idea of at least simulating it on simple examples lets you check a couple of important questions.
操作么?我在这里发现了一个错误,我也可以通过运行不同的测试集,或者运用print声明来发现这个错误,但是至少应该用简单的例子来手工模拟下,代码的思想可以让你,对一些很重要的问题进行检验。
So just to reinforce this, I could run gcc math2.c but I'm getting a little tired of this a.out convention and recall that there's this utility called "make" that right now doesn't really improve much, other than give it a better name.
所以我强调这点,我可以运行“gcc,math2,c“,但是我不是很喜欢a,out这个默认的名字,想取消它,那么这里有个叫做“make“的命令“,这个命令现在没有很大的改进,只是把用来更改名字用的。
- You then run a compiler, in our case called "GCC" -- -- one of the world's most popular -- and then you can run it with some number of switches, these command line arguments as they're called that somehow influences the behavior of this program.
然后你们运行编译器,在这里我们使用叫做“GCC“的编译器-,这是全球最流行的-,然后你们可以通过一些命令来运行这个编译器,这些命令行参数可以,影响这个程序的行为。
And then you can delete it once you're sure your code is working right.
当你们能够确定你们的代码运行正常的话,你们可以把这个“printf“,语句删除掉。
And then I run a loop in which I read something in, I check to see if it's the right type, if it is, I change that variable to say it's now the correct type, which means the next time through the loop, I'm going to say I'm all set and I'm going to bounce out.
因为我还没输入,然后我运行一个循环,循环内部我输入一些东西,然后看看是不是正确的类型,如果是的话我改变input,Ok为真,来证明输入数是正确的类型,这就意味着下一次运行这个循环的时候,就可以跳出循环继续执行了。
应用推荐