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.
当然,你可以有好几种方法来实现这一目标,但是其中一种方法,只需要用到我们刚刚看到的那种语法。
Then I'd be multiplying a float by 5, so that's a float times an int.
然后我们把这个浮点数乘以,那是浮点数乘以整型数。
- And then I divide by an int -- that's okay because so long as you have a float involved at some point early on, you're okay.
然后我除以一个整型数-,那是可以的因为现在为止,我们在之前已经,引入了一个浮点数,你是对的。
int Let's instead declare another int just as we've been doing all this time.
我们声明另外一个,就像我们一直做的那样。
So for now assume it's got to be an int or a char.
所以现在假使它是一个整数或字符。
GetInt Let's call her, get int, for today.
我们今天叫她为。
It's gonna hold integers so I have to say int as we'll see 0 and set it equal to 0.
因为需要是整数,所以我们把它定义为int类型,并初始化为。
Y Why don't I say int temp gets X. Let's say Y oh, sorry, X gets Y and then Y gets temp, this 2 would fail.
为什么我不说明,int,temp,=,X,让我们说明,哦,对不起,X=Y,然后,Y=temp,这两行将失败的。
So we've seen a lot of this, for instance, in office hours and maybe you too have done or are currently doing this, but there's a problem with writing a statement, like print F, followed by, get int, alone.
我们看过很多这个,例如,在办公时间,可能你们做完了或还在做这个,但是写语句的时候有个问题,就像printf,紧跟着的是GetInt,单独的。
- We know from Wednesday if -- briefly -- that there's this thing called a "char" or "char," depending on how you want to pronounce it, which is just a single character but where there's also an int.
我们知道从周三起--简单说下-,我们有个叫做“char“或“char“,看你们怎么读它了,那代表一个单一的字符,但那里会有个整型数与之对应。
y A square it's called X, another square it's called y and now this time I'm doing pointers to int not points to char.
一个叫做x,另外一个叫做,这一次是int型指针,不是char型指针。
- And actually, it's worth noting an int -- 4 billion -- we didn't even solve that problem.
事实上,int数据类型还是没什么用--40亿-,我们还是没有解决那个问题。
So this line here declares a variable, just storage space called "x" and it's of type "int," which means an integer has to go in it.
这里的这条线声明了一个变量,一个叫做“x“的存储空间,它的类型是“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数,因为那是无效的。
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,我们在前几个演讲中,一直讨论的东西,任何时候你声明一个变量,你必须指定它的类型。
I culled int and as promised, it's going to yell at me by saying "retry."
我不用int数,正如预期的那样,它开始对我大叫,并且说“重试“
- And, in fact, let's see -- -- don't do this at home or on our systems -- but let me go ahead and do nano don't do this dot C. Let's go int main ahead and do int main void.
然后,实际上,让我们看看-,不要在家里或者在我们的系统上这样做-,但是让我们继续处理nano,dontdothis,c文件,让我们继续。
Then I'm declaring a variable called n, it's of type int.
然后我声明了一个变量n,它是int型的。
So int is gonna stand for integer, it's just a number.
大家都知道int代表整数类型,一个数字而已。
So that's what it means to get an int.
所以获得一个int数是什么目的?
Okay, obviously that's not an int.
好的,显然那不是一个int数。
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数,对输入进行引用,返回给你。
应用推荐