• I get the int and store it in n. The switch statement takes inside its parenthesis an int or a char or some primitive type.

    我得到一个整数并把它存储,到n中,switch语句的圆括号里可以是一个整数,或者一个字符或其他的基本类型。

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

  • A few of you were probably wondering, "Well, how do I actually get the int from the user?"

    有的同学可能想知道:,“我们怎么通过用户获得那个int数值“

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

  • Well basically what we're doing is we're giving ourselves the ability to create data types the same way that we have some built-ins, so we have things like int, float, string, these are built-in data types.

    就是要赋值我们自己创建,和内置的数据类型,相同的数据类型的能力,我们有一些内置的数据类型,如int,float,string等,如果你考虑下这些数据类型。

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

  • But if we know that 65 is the int that maps to the capital letter "A," we've already seen verbally that you can convert letters to numbers and numbers to letters, and so here's the syntax with which we'll soon be doing that.

    如果我们知道65是个整型数,对应的是,大写字母“A“,我们已经口头地说明,我们可以把数字转换为字符,字符转化为数字,所以这里就是我们将要学习的一种语法。

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

  • Expect the address of an int but here in the context of the function itself inside the curly braces, it means go to that address.

    一个整型数的地址,但是在函数,大括号中的环境中,意思是定位到那个地址。

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

  • 4 So even if the correct mathematical answer is 1.4 or whatever, when you divide an int by an int, you only have room in that variable, in the response for an actual integer.

    所以即使那个正确的答案是4,或别的数值,当你用一个整型数除以一个整型数,在那个变量的返回值里,只有,存储一个整型数的空间。

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

  • Well, if intuitively the problem is the result of dividing an int by an int, surely a solution is: "Don't do that," right?

    好的,直观地看,如果那个问题的原因是因为整型数除以整型数的话,无疑有个解决方案是:“不要那样做“,是吗?

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

  • The result is that when you divide an int by an int, the answer no matter what is going to be an int.

    当你把一个整型数除以一个整型数时,无论如何答案将会是一个整型数。

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

  • Well, you can implement this in a few different ways but here's one approach that uses some int counter=0 of the syntax we just looked at, int counter equals 0.

    当然,你可以有好几种方法来实现这一目标,但是其中一种方法,只需要用到我们刚刚看到的那种语法。

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

  • The problem only arises if you have an int divided by an int.

    这个问题只会发生在,当你用一个整型数除以一个整型数的时候。

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

  • Well, all this time int on the blackboard I always draw an int as a square.

    嗯,向来,我在黑板上用一个正方形表示一个。

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

  • Now get int *y so now I'll use the board for things I can't really draw very well with the keyboard so what does the memory of my program look like at the moment?

    现在,=,int,*y,现在我使用黑板,我用键盘画的不是很好,那么此刻,我程序中的内存看起来像什么?

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

  • It takes an int; deal with it when you get to it and then once you look through the whole file, should you find -- ultimately find the actual code that defines or impliments this thing.

    它携带一个int数,当你获得了它就处理它,然后一旦你查看整个文件,最终你将发现实际代码中,定义或执行了这个东西。

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

  • So input is an int called F, print out to the screen or your piece of paper the value of C. Odds are you only need two, maybe three lines of code for this, but the goal ultimately will be try it on your own.

    所以输入是一个int类型的F,在你的屏幕上,或你们的纸上打印出C的数值,可能你们需要两行或者三行的代码,但是最终的目标需要你自己独自尝试。

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

  • Well, int is almost always 32 bits at least so far as we've seen so, in fact, any time I draw a pointer hence force I'm just going to draw a square as well because they are, in fact, the same size usually in memory.

    嗯,int几乎总是32位的,至少我们至今所看到的是这样的,每次我用一个正方形表示一个指针,因为实际上他们,在内存中的大小是一样的。

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

  • And we'll see if you try to mess with our functions by providing a string when we want an int, or providing an int when we want a string, you may very well get yelled at and the user will have to retry.

    我们可以看到,如果你尝试打乱我们的函数,当想要一个int数时我们提供sting型,或者,当想要一个sting数时我们提供int型,你可能会被吼叫,然后用户不得不重新尝试。

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

  • So unlike an int, this is the type of number that can have numbers after a decimal place.

    所以,不同于int,这个类型的数字,可以有小数位。

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

  • Now at this point in the story, I've got a variable called n. I've stored it in int.

    现在这个故事的这里,我获得了一个变量n,我把它存储成int型的。

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

  • malloc I'm going to now use this new, fancy function called malloc and I'm going to say x gets the return value of malloc of the size of an int.

    我现在使用这个新的,别致的函数,然后我指明x,=,malloc的int型数据的大小,的返回值。

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

  • Well, simply with the * notation at least on the way in when you declare the function called swap, you simply say this is not going to take an int and another int because that's useless.

    好的,简单说,当你声明一个函数调用swap函数时,使用*符号,你可以简单说,这不能使用一个int数和另外一个int数,因为那是无效的。

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

  • float So thus far, when we've defined -- declared an int and a float, 2 and so forth, we just put one value in there, the number 2, the number 3.14, just one single value.

    至此,当我们定义--声明一个int,和一个,等等,我们只要在那里放置一个值,数字,数字3,14,只有一个值。

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

  • If you want to do the opposite process, you simply "cast to an int from a char."

    如果你想做相反的转换,你就告诉计算机,“把那个char型数据转换成int型处理“

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

  • i So I have up here at the top of my program a variable called i 0 of type int, and I have to initialize it up here to zero.

    所以在程序的顶端我有一个int类型的变量,我需要把它初始化为。

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

  • So there's no mention of int, and yet we've been saying for the past couple of lectures, that anytime you declare a variable, you absolutely have to specify its type.

    这里没有提及int,我们在前几个演讲中,一直讨论的东西,任何时候你声明一个变量,你必须指定它的类型。

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

  • A If you want to convert a number like 65 to the letter A, you just have tell the computer "cast that int to a char."

    如果你要把一个像65这样的数字转换为字母,你只需要告诉计算机“把那个int型数据转换成char型处理“

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

  • int No. Even though the key word has changed from char to int, the * is the same and the fact that I've got a * there is saying this is a pointer to an int or a pointer to a char pointers are always the same size on a computer.

    不,即使即使关键字从char变成了,指针的大小还是一样的,我用*表示这是一个int型指针,而不是char型指针,在同一台机子上,它们的大小是一样的。

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

  • I have to change the prototype of this function to say that swap no longer takes an int per se or another int per se, but rather it takes two pointers, two ints, and in fact, it's on the very last page if you're still flipping.

    我改变了这个函数的原型,来说明swap不再携带那两个int数本身,而是携带两个指针,两个整型数指针,实际上,它是在最后那页上。

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

  • > Yes. You don't actually store the return value of, get int.

    >,是的,你实际上没有存储GetInt的返回值。

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

  • You've used get int, get string, or the like perhaps already.

    你们用过GetInt,GetString,或者其他的。

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

  • So we'll talk a bit more about this idea of functions today, but, get int, again, can think of it as a black box, whose purpose in life is to prompt the human for input and pester the human if he or she doesn't actually give it int, but then once it has that, has entered it from the user, it's quote unquote, returns it to you.

    所以我们进今天将多讨论点这个函数的概念,但是,GetInt,我们可以把它当做一个黑盒子,它的唯一目的是提示人们来输入,并且如果他或她没有,给它int数,则会纠缠用户,但是一旦它得到了,用户输入的int数,对输入进行引用,返回给你。

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

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

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

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