• Now, how can I use code that someone else wrote?

    那么,我们怎样才能用别人写的代码呢?

    哈佛公开课 - 计算机科学课程节选

  • In fact, this example would compile because you can use curly braces in this way to encapsulate lines of code, but realize for now, that, not good.

    实际上,这个例子可以编译,因为你可以用这种方式来压缩代码行,但是请认识到,那个,不太好。

    哈佛公开课 - 计算机科学课程节选

  • By the time you get to the end of the term, you're going to be dealing with some fairly complex things, so one of the things you're going to see is, we're going to make heavy use of libraries, or code written by others.

    当你临近期末的时候,你们将要解决一些,相当复杂的难题,因此你们将会看到的其中一点是,我们要充分利用图书馆,或者别人编写的代码。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • > That lets the compiler know that you want to use some actual compiled code from that library.

    >,那是告诉编译器我们想要在程序库中,使用一些当前的编译后的代码。

    哈佛公开课 - 计算机科学课程节选

  • It's inside the memory of the machine, which means we have access to it, we can change it, we can use it to build new pieces of code, as well as we can interpret it.

    它在机器的存储器里面,就是说我们可以进入它,改变它,可以用它来编写新代码,当然也可以翻译它。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • If you want to make sure both conditions are true and they both have to be true for any code to be executed, use ampersand ampersand.

    如果你想保证两个条件都成立,或者它们两个都必须为真值,才能执行一些代码,那就使用“&&“

    哈佛公开课 - 计算机科学课程节选

  • In a high-level language, square root might simply be a primitive that you can use rather than you having to go over and code it.

    一个高级的语言,平方根可能仅仅,只是你能使用的一个基本要素,而不是你需要去编译它。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I want to talk a little bit about how you use the things we've been building in terms of functions to help you structure and organize your code.

    第一件事情就是我要谈下,怎么利用我们,所做的能在方法方面,帮助你们组织和优化代码。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And to do this, I'm going to use some code that I've already typed in.

    为了达到这个目的,我会去使用一些,我已经写好的代码。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So if you're coming from prior background, your code might work a little differently on a different system if you don't use those flags.

    如果你来自一个先前的背景,如果你们没有使用这个版本标志的话,在一个不同的系统中,你的代码可能运行地不太一样。

    哈佛公开课 - 计算机科学课程节选

  • You need multiple lines of code, you need these days to use something called a scanner class.

    你需要写许多代码,你要学会使用扫描仪。

    哈佛公开课 - 计算机科学课程节选

  • I want to just use it, I shouldn't have to worry about what variables I use inside of it, I have shouldn't have to worry about where that is in the code, I should be able to just abstract it away. And that's what we want to add today, are those two things.

    我只是想使用它,我不用考虑我在这段代码中,使用的是什么变量,我完全不用考虑代码的内容,只要抽象就好,我们今天想补充的内容就是这两点。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Right, so how do you use the idea of functions to organize code?

    好,你们是怎么利用方法,来组织代码的呢?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I'm going to use my own special program that will color code things for me in class, but the idea is the same; it's a text editor.

    我将用我自己专门的程序,那个会分类为我标出代码的颜色,但是那个思想是一样的,这是一个文本编辑器。

    哈佛公开课 - 计算机科学课程节选

  • When we start building up code, we're going to use commands. Or statements.

    当我们写代码的时候,我们会用到命令或者声明。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • 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.

    好,那么,让我给大家讲下,我想用的另外一个工具吧,也就是,我已经写好了这一块代码,我应该去检查检查,那么我可以去运行它,但是特别是当我想要调试代码的时候。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I stress it in particular because I know you're all going to get into this stage; you've got a problem set due in a couple of hours, you're still writing the code, you don't want to waste time, and I'm going to use quotes on "waste time", doing those extra things to do the defensive programming, you just want to get the darn thing done.

    我特别强调了这一点,因为我知道你们都会慢慢成为程序员;,你在写代码过程中造成了一系列的错误,你还在写代码,你不想浪费时间,我想把“浪费时间“用引号圈起来,浪费时间来做因为防卫性程序设计,而带来的这些额外的事情,你只想赶紧把程序写完,这不是一个好习惯,因为当你做完回头。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I've certainly written code that has this problem, I've tried to use my own code that has this problem, and good to us, right, good hygiene, I'm going to use that word again here, of getting into the habit of writing defensive code up front, it's part of that collection of things that you ought to do is a great thing to do.

    我举手了吧?,我当然写过犯这种错误的程序了,我也尝试过应用含有这种错误的代码,不错,好的卫生,我还是要用这个词,对我们有帮助,养成写防卫性,代码的好习惯,是你应该做的,一系列事情之一,也是我们日后要做的主要的事情。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Now that I've written sqrt, I can just use it anywhere I want in the code. You've got to rely on the fact that I wrote it correctly, but you can basically suppress the details of how it's used.

    就是忽略细节,既然我已经编写了sqrt函数,我可以在代码的任何地方使用它,你完全可以依靠,我已经编写的这个函数。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • But here, if I decide I'm going to store things not in x and y, but with some other set of names, for example, I've gotta go back into these pieces of code that use the points, and change them. So I've lost modularity.

    除了要改下借口,但是这里,如果我决定,我不把值放在x和y中,而是和其他一些变量名进行绑定,例如这样的话,我就得回到使用这个点的代码,那儿去做更改了。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So that is a flag that tells the compiler that I want to use or link into my own program code that someone else wrote that lives somewhere else on the system whose moniker is CS50.

    所以那是一个标记,用来告诉编译器我想使用,或连接我自己的程序代码到一个叫做CS50的系统中的程序,可能其他人在那个系统写了这些程序。

    哈佛公开课 - 计算机科学课程节选

  • The standard library, that first line of code, it's not strictly necessary but any time you use a function, a tool that someone else wrote that lives in that so called library, you do need that include line as we'll see.

    标准库函数--第一行代码,严格来说,不是每次都要写的,但是一旦你调用某个别人写,的函数,而这个函数又恰巧位于标准库里面,你就要像我们看到的这样,把它include进去。

    哈佛公开课 - 计算机科学课程节选

  • So conceptually the key difference here, besides the syntax looking slightly different, it just means that if you want a chunk of code to execute no matter what initially, ; you can use the do while loop; if you want to check a condition first, you can use the while loop.

    所以概念上,则关键的区别是,除了语法看起来有点不同,它的意思是如果你想要一段代码,最初无论如何都要执行,你就可以用do,while循环;,如果你想要先检查条件,你可以用while循环。

    哈佛公开课 - 计算机科学课程节选

  • First of all, two parameters. It's OK. All it says is, when I call this, I need to pass in two parameters for this to work. All right? Now, if I want to use that, I'm going to use a second piece of code here, called Barnyard. I'm going Barnyard to read in a couple of values, convert them into integers, and then I'm going to use solve to get a solution out.

    注意我得到了什么,第一,两个参数,它的意思就是我调用这个函数,我得给它输入两个参数,明白了吗?,现在如果我要使用它我得用,这里的第二段代码,也叫,我将读入一组值,将它们转化为整型,然后我会用solve得到一个解决方案。

    麻省理工公开课 - 计算机科学及编程导论课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定