All right, you can see that this little piece of code, it's got a loop in there, and what's it doing?
好,你们看到的这一小块代码,是做了一个循环吧?,他在做什么?
So this we would want to delete in order for the code not to run the risk of crashing, but let's now see this was made by an excellent teacher out at Stanford University.
我要按顺序删除它,不要冒崩溃的风险,但是这个是由一个来自斯坦福大学的,优秀教师做的。
Well just to see what we know what we're doing, let's look at this code here.
我们下一步该去怎么做呢?,好,让我们来看看。
So let's actually see how we solve this with this function with actual code.
然我们看看怎样用,这个函数和代码解决这个问题。
Yeah, if my machine will come back up, there we go. So, I'm going to now go ahead and write a little piece of code, and I put it here and I hope you can actually see these better this time, let me uncomment that region.
让我们写出代码来吧,好,如果我的电脑能回来的话,好了,那么,我要去写一小块代码,我把它放在这里以期望大家这次,能看的更清楚点。
And you can see that in this code here.
它首先是显示出开始点和尾点的位置。
Because what you don't see in this file is any code a that actually says put a letter of the alphabet at the top left hand corner of the screen and then put the next character to the right in other words, I'm taking for granted at this moment in time that my computer knows how to print something to the screen.
就是这些你在本文件中看不到的一些代码,实现了将首字母,放在屏幕的左上角,然后把其他字母加在其右边,我想当然地认为,我的电脑知道如何打印相应信息到屏幕上。
All right. If you flip to the second side of your handout, you'll see that I have a piece of code there, that does this-- let me, ah, I didn't want to do that, let me back up slightly- this is the algorithm called search.
你可以看到实现这个功能的代码,让我,额,我不想这么做,让我们回来一点,这就是命名为search的算法-,我们来看看这个算法吧。
cs50 h It's not called standard io.h, it's called cs50.h. That's where the code we wrote for you will live and then we'll see how to do this in examples today onward but we wrote for you some tools, some functions that calls GetChar for get a character.
当然不是标准输入输出库了,而是叫做,这里面有一些我们写的代码,等一下我会举几个例子,我们写了一些函数,比如GetChar,意思是得到一个变量。
应用推荐