And if it returns a value, you've got to do something with that return value too, much like we did up here.
如果它返回了一个值,你便用那个返回值,做一些事情,就像我们刚在上面做的。
I don't have to go read what it printed out in the screen. This has returned a value that I can use. Because I could do a test to say, is this a return value? If it's not, I'll do something else with it. So the binding is still there, it simply doesn't print it out.
我不想读到屏幕中打印出来的这行字,程序返回过一个我能够使用的值,因为我可以做个小测试,来说明这是否是返回的值,如果不是,我可以做一些其它的事,而这个绑定依然在这儿,没有打印任何东西。
The prototype is just its return value, its name, and its arguments, if any.
原型就是他的返回值,它的名字,它的参数之类的。
The only thing that you have to put in the function prototype, ; again, is three things; one, the name of the function; the return value; and its arguments.
你唯一要加入到函数原型中的东西,是有三个东西,一,函数的名字;,返回值,和它的参数。
And it's up to me to put that return value in a variable.
那个放在变量中的值是取决于我所赋的值。
Two, the arguments or parameters, and three, is the return value.
第二个,参数和参量,还有三,是那个返回值。
Literally, return the control from this function, and take the value of the next expression, and return that as the value of the whole computation.
正如字面意义上说的,从这个函数返回,然后取得下一个表达式的值,并把这个值作为整个计算的结果返回。
So, after the second line for code here char * s1 gets the return value of get string this is what the state of our world looks like.
在第二行之后,这个代码char,*s1,等于GetSting的返回值,这就是它看起来的状态。
If GetInt's return value is greater than zero, what do, in plain English?
如果GetInt的返回值比0大,该干什么,用简单的英语说?
> Yes. You don't actually store the return value of, get int.
>,是的,你实际上没有存储GetInt的返回值。
- So now if Christiana doesn't actually -- if either programmer or who's programming these little puzzle pieces, don't actually do anything with this return value, and I call, get int, she wants to hand this piece of paper -- to me, but if I don't actually assign -- no, no, I just messed up the demo.
现在如果Christiana没有-,如果程序员或谁在编写这段代码,不要对这个返回值做任何事情,我调用GetInt,她把这张纸给我,但是如果我没有赋值-,不,不,我刚才把这个演示搞乱了。
So you're implementing this black box, and if its purpose in life is to actually return a value, you have to tell the compiler what kind of value to expect, and this is going to have ripple effects.
你在实现这个黑盒子,如果它的目的是,返回一个值,你必须告诉编译器你期望的是什么类型的值,这个将是一个连锁反应。
Then if the weight of i is less than the available weight, I can return the value of i.
然后如果i的重量,小于剩下的重量,我将返回i的价值。
- Then you declare a float called f and then assign it -- -- let me scroll up for the folks in front -- that give return value of GetFloat.
然后你声明一个float类型f,再赋值-,让我向上为你们回滚到-,给出了GetFloat的返回值。
And the reason that we now on the second line have the equal sign is because this function GetString has what's called a return value.
我们之所以,在第二行代码GetString前面加上等号,是因为这个函数会带回一个,返回值。
And actually, if I don't want to clobber, as we say, overwrite the value of my variable, ; I could declare another one and store the return value in Y; Y so now I have two ints in memory; X and Y, 3 one with two, one with three.
实际上,如果你不想彻底清除,像我们说的,覆盖那个变量的值,我可以申明另一个变量Y,并在Y中保存那个返回值;,现在内存中有两个int数,X和,一个的值为2,一个为。
Well, the return value of toupper so that literally changes this.
好的,toupper的返回值,也就改变了这个。
I check the return value of GetInt is greater than zero.
我检查了GetInt的返回值比0大。
But it's a valuable thing. It says, in each case, I return some useful value from this procedure.
但是这就是变量,是在每个例子中,我从这个程序中返回了一些有用的值。
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型数据的大小,的返回值。
X I'm passing an X, and yet I'm also assigning the return value to X. So just intuitively what's going to be the effect of this one line of code?
我传一个X,之后我把返回值赋值给,很明显,这一行代码,将会产生什么作用?
It will return me some random value from either the Gaussian or the normal distribution.
它会给我,返回符合高斯分布。
And then the only other difference is obviously, it's a function I need to return a value.
然后还剩下一点明显的区别,对于方法我要有返回值。
So the first thing I'm going to do is, I'm going to try and return the value in the memo.
所以我要做的第一件事,就是我将会尝试将,总价值返回到memo中。
Right.? I'm going to set up a variable to say, none what's the answer I want to return, is it there or not. Initially it's got that funny value none.
看我要找的答案在不在数组里面,初始化为,然后建立一个索引。
minus volatility to plus volatility it will return any value in here.
浮动值到+浮动值之间等概率地,去返回一个值。
Except, before I return the value, I save it.
除了我再返回之前,还保留了这个值意外。
I try and return the value.
我会尝试返回这个值。
I'm going to say, gee, p2 is the x value the same in both of them, and if it is, and the y value's the same, then this is the same point, I'm going to return true.
这样的数据对象,我会把它们命名为p1和,我会去查看,看看两个对象中,的x值是不是相同,如果相同的话,就去查看y值是否相同。
It's defined in CS50's library; its sole purpose in life is to ask the user for a floating point value and return it.
它被定义在CS50的函数库中,它的唯一目的是,向用户询问一个浮点数的值,然后返回它。
应用推荐