• So the take away is that if the user actually gives me two or three or four or whatever, this is this expression "is n less than 1" is going to evaluate to false if it's actually two or three or four or whatever.

    所以先不管用户实际上给我,3,4还是其他数,这个表达式,“是否n小于1“将被评估为错误的,如果输入额是2,3,4或其它的数。

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

  • I mean what if you're running so many things, what if the user has copied and pasted their thesis and just pasted it at the blinking prompt such that you're now out of memory because your computer is somewhat limited in memory so get string cannot possibly return all those characters or fit all of those characters in memory and return to you the address of the first.

    如果你运行了很多程序,假使用户复制粘贴了他们的论文,只是粘贴在光标提示符那里,这样就出现了内存不足,因为你们的计算机的内存是有限的,所以GetString不可能返回所有的字符,或者保存这些字符到内存中,并且返回第一个字符的地址。

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

  • So, if you like, I've built a separation between the user and the implementer.

    好,也就是说这样做,把用户和实现者分离了。

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

  • -- Else if n is greater than 4 and n is less than 6 -- 7 let's call it medium -- else if n is greater than or equal to 7, -- less than or equal to 10 -- let's call it "big" -- and if the user typed in zero or negative 10 or 20 or whatever, let's just use the all-inclusive else block and just say, "You picked an invalid number."

    否则如果n大于4,并且n小于-,我们叫它为中间数--否则如果n大于等于,小于等于10--我们叫它为“大数“,如果用户键入了0或者-10或20或其它的,让我们用一个广泛的else子句,只需要说,“你选了一个非法的数字“

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

  • Now, if I've asked the user for a string and then a moment later I ask the user for another string, well, they're going to end up in different locations in memory just by nature of get string.

    现在,如果我要用户输入一个字符串,一会儿之后我要用户输入另一个字符串,他们最终是在,不同的内存地址中。

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

  • We look at what emails you reply to if you reply in theory that suggests this user must care about whoever sent this email or the topic they are in.

    我们看看哪些邮件要回复,如果你回复了,理论上来说这表明了用户一定很关心,发件人以及邮件的主题。

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

  • Now if I am difficult with the user positive1 and I compile make positive1, and I then run positive1.

    现在如果我和用户有点不和谐,我编译正positive1,然后运行。

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

  • GetDouble If you just want a single letter from the user, GetDouble.

    如果你想得到一个单独的字母,用。

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

  • If you want to get some input from the user, my God I don't want to have to program it to low level zero and 1 just to get keys from the keyboard; please let there have been someone who does that for me and indeed there are an increasingly sophisticated options that you can pull off the shelf.

    如果你想获得一些用户的输入数据,我的上帝,我可不希望在键盘上敲入0,1的低水平方式来编程;,希望有个人能帮我做这件事吧,但是现有的选择,也变得日益复杂了。

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

  • That goes back to that idea of sort of discipline coding. It's easy to have assumptions about what you think are going to come into the program when you writ it. If you really know what they are use them as search, but if you think there's going to be some flexibility, you want to prevent the user getting trapped in a bad spot, and exceptions as a consequence are a good thing to use.

    这又回到了规范编码的想法上来了,在你写代码的时候考虑,什么会进入你的代码的思考是简单的,如果你真的知道,他们是用他们来做搜索的,而你希望有一定的灵活性,你想要阻止用户,陷入一个艰难的境地,那么异常是非常实用的。

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

  • Otherwise, what was the point of getting a string from the user if I'm not handed the result to actually do something interesting with.

    否则的话,它不把值带给我们,我们就做不了想做的事情,那我们还要它有什么用呢?

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

  • So if I type "man sleep," this is going to give me the user's manual for a program called sleep, but there's a gotcha and the problem set it makes clear, sleep notice that it says at top left sleep one.

    所以如果我键入“man,sleep“,它将,给我一个叫做sleep程序的用户手册,但是这里有个参考信息,它使问题更清晰,请注意它指明在左上角。

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

  • I can't rely on Professor Guttag if I give this- if this code to him, I can't rely on him to type in a float. Actually I can, because he's a smart guy, but in general, I can't rely on the user-- I wouldn't do it right to see if you did.

    当Guttag使用这段代码的时候-,我不能相信他一定会输入一个浮点数,实际上我能因为他很聪明,但是总体上来讲,别相信用户一定会按照规则来-,我会故意做错来试试你的程序的。

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

  • If you called get string multiple times, surely you've been able to get different strings from the user.

    如果你调用GetString好几次,你可以从用户那里获得不同的字符串。

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

  • If you instead use GetString, same thing: blinking cursor, the function is just going to wait for the user to type a word, a sentence or whatever, and then hit Enter.

    如果你用GetSring来代替它,同样的:闪烁光标,那个函数只是等待用户来,输入一个单词,一个句子什么的,然后敲回车。

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

  • I probably whip out a do while loop very rarely, but very often when programming games or any program that takes user input and has to check that user input and yell at the user if they're messing with you or aren't providing what's expected.

    我可能很少用do,while,循环,但常常是,当编制程序游戏或需要用户输入的程序是,需要检查用户的输入并提醒用户,如果他们干扰了你,或没有提供所期望的输入。

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

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

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

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