"they would like to receive a message that uses some kind of code, and instead of sending a message that reminds them of their pill, they would like a motivational message, like for example, 'it's time for your life.'" Services like that have been shown to work in low-income countries, and now they're starting to appear in richer countries.
VOA: standard.2010.02.24
Pseudo code. Now, you're all linguistic majors, pseudo means false, this sounds like code that ain't going to run, and that's not the intent of the term. When I say pseudo code, what I mean is, I'm going to write a description of the steps, but not in a particular programming language.
伪代码,基于你们都是学语言的,伪代码意味着不正确,这听起来就像是没法运行的代码,这可不是我们学这个的目的,当我说到伪代码的时候,我的意思是要对步骤进行一个描述,而不是某种特定的编程语言。
You answered that you majored in course 2. It sounds like a secret code to outsiders.
你刚才回答你的专业是课程2。这在外人听起来就像是秘密代码一样。
Right. If you look at the rest of that code, gee, it looks a lot like what I had elsewhere.
好了如果你看看剩下的代码,天呐,看上去就像我在别的地方写过的。
- Writing code that just looks-- I'm not even sure what this is supposed to look like, a little flower or pinwheel or something like that.
这代码写出来有点像-,我不确定这像什么,像朵花,或纸风车,或其他什么东西。
Just like people have a genetic code, perhaps, that gives us various instructions that we begin to follow out, or certain innate psychology or what have you.
就像人类拥有基因编码,给我们传达各种各样,得以遵循的指示,或者是某种与生俱来的心理,等等等等
Honor to so many of us sounds quaint, like an honor code or the Boy Scouts' code or something like that or something primitive, some kind of primitive ethic which we therefore don't really understand.
荣誉,对我们中大多数而言,听起来都会很奇怪,这就像是在说荣誉代码,童子军守则或一些类似的东西一样,亦或是一些非常原始的理论,以致于我们根本不知道这是在说什么。
One of the things we talk about is like developing a code of ethics
我们经常谈论的就是要制定一套行为准则,
or whatever. Like, you know, you're speaking the secret code,
好像你在说密码一样,
We won't make you write dramas like Pirandello, but we're going to try make you at least write good code.
我们的函数中的东西,我们不会让你去写皮兰德娄的荒诞剧,但是我们会教你写漂亮的代码。
I know this is a simple example, but when you mature as a programmer, one of the first things you should do when you sit down to tackle some problem is write something like this pseudo code.
我知道这是个很简单的例子,但是当你们成长为一名程序员后,当你们碰到问题后第一件事情就是,该写一些类似于,伪代码的东西。
Give you some examples. What have we talked about? We've talked about things like using comments to highlight what you're doing in the code, to make it easier to debug.
给大家举些例子,我们一直在强调什么来着?,我们讲过要用注释来说明,你在代码中进行的操作,以便于调试。
You write the source code, the stuff that looks like this and then you save your file, and now you just have a text file.
比如你们写出像这样的源代码后,保存,你将会得到一个文本文件。
> This is what the code looks like.
>,代码看起来是这样的。
Why are you, like, writing out code?
你们为什么写代码?
Imagine that I've written code like this, written a bunch of code.
想想下我已经写了一些,像这样的代码。
OK. So if I look at this code, first of all I'm calling search, it just has one call, so looks like search is constant, except I don't know what happens inside of b search. So I've got to look at b search.
首先调用一下搜索,就一步调用,看起来搜索是固定的,除非我不知道二分搜索的原理,那我们来看看二分搜索吧,所以让我们看看,第一行打印出来的内容。
Well, now I go through code very much like what I did for max val in the first place. I check whether it's 0, et cetera, et cetera.
现在我会捋一遍代码,就像我之前捋maxval函数一样,我会检查它是不是0等等等等。
This chart, very boring and uninteresting but useful to say there are very well defined rules as to when you're writing code, what operators, like what syntax should get evaluated first.
这个图表,看起来很烦,很无趣,但是它很有用,有非常明确的规定,譬如,当你写代码时,就会涉及操作符的优先级。
I would like you to look at this piece of code right here called isPalindrome.
我将会输入一个字符串,命名为s,并局部赋值。
Well, what is code like that from the world of Scratch gonna look like?
那么像Scratch那样的代码,长啥样子呢?
But what looks like this orange block as of now in Scratch, add orange to your so called inventory, well, it's gonna take at least two lines of code in C to actually create the inventory array with this first line and then put something like the word orange inside of it.
就好比Scratch里面橘色的这一块,把“桔子“加到所谓的“清单“里面去,在C语言中至少需要两行代码来实现,第一行代码创建一个货单数组,第二行就需要把“桔子“放进去。
And you can write your source code in it but to compile something you don't run a command like GCC and then the name of the file, you instead click a button.
你们可以在上面写源代码,如果要编译的话,不用像GCC这样要输入命令,文件名,只需点击按钮就可以了。
应用推荐