And the equation of state, pressure versus volume at constant temperature, is going to have some form, let's just draw it in there like that.
系统的态函数,恒温下压强比体积,变化曲线,就像这样。
So when you define a function, you have, as we've seen these curly braces, that define all ; of the code that's associated with that function; open curly brace code, close curly brace, that is the function.
当你定义一个函数,就像我们看到的这些花括号,定义了与,那个函数相关的所有代码;,左花括号,代码,右花括号,这就是一个函数。
What I want to do is I want to draw a picture, a little bit like we did for the partnership game.
下面我来画出函数图像,这与合伙人博弈的有点像
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等等等等。
So what does that tell us about a state function like u?
所以这告诉我们的是,这过程中像u这样的态函数式怎么变化的?
It's a little redundant, admittedly, but I include not the same function, but just its prototype, as I say in the comment here.
它确实是有点长的,但是我包含的不是同一个函数,而只是一个原型,就像我这里的注释所说的。
You have to pass it as input to another function, as you'll see as possible in problem's Set One specification, but it's ultimately up to you.
你需要把它传给另一个函数当入参,就像你们将,在习题集1中可能看到的,但它最终取决于你。
And, in fact, it kind of looks like a function, and yet here's a semicolon I just said that can get you into trouble, and yet that's not actually a function, because there's no interesting lines of code, because it turns out the interesting code is down here at the bottom.
实际上,它有点像一个函数,并且这里有一个能够使你陷入麻烦当中的分号,那个事实上也不是一个函数,因为这里没有有用的代码,因为,有用的代码都在底端。
Now if you call a function, swap like increment or cube or swap, or in this case, foo, those variables are the parameters to that function, end up getting stored next in memory.
现在如果你调用一个函数,像increment或者cube或者,或者在这个例子里,foo,这些变量都是,函数的参数,在内存中存储。
And just as with variables, you should use some common sense, some style here, and the function's name should X Y communicate what it does, calling it X or Y or Z is generally not all that helpful.
就像变量,你使用一些常识,一些类型,和函数名需要,传达它所做的事情,把它叫做,或者Z通常是没有什么用处的。
Well, you don't have to just take what you've been handed round in life, functions like print F or round or maybe other functions you've seen in super sections or by poking around.
好的,你没必要把传给你的参数保存起来,像函数printf或者,或者你们看到的其他的函数,在超级课程中或闲逛的时候。
The standard library, that first line of code, it's not strictly necessary but any time you use a function, a tool that someone else wrote that lives in that so called library, you do need that include line as we'll see.
标准库函数--第一行代码,严格来说,不是每次都要写的,但是一旦你调用某个别人写,的函数,而这个函数又恰巧位于标准库里面,你就要像我们看到的这样,把它include进去。
Well, if you want to call a function, it's like putting another tray on that stack of trays and that tray represents a chunk of memory that, that function can use.
嗯,如果你想调用一个函数,这就像把一个托盘放到另一个托盘上,托盘代表一块,函数可以使用的内存。
And we've only just begun using it, but it has just a bunch GetInt GetString GetDouble of very useful functions like GetInt, GetString, GetDouble, And so as those names imply, you can just cull these functions with no arguments and you'll get back that data type based on its name.
我们刚开始使用了它,里面有很多的,有用的函数,像,所以,那些名字暗示,你可以挑选这些,没有参数的函数,然后你可以通过它的名字,获取他们的数据类型。
X So here I'm declaring another variable called X, and this is totally legitimate because I already know that if I'm implementing a function like swap or increment, I can absolutely take input.
这里我声明另一个变量,这个完全是合法的因为我已经知道,如果我执行一个像swap,或,increment的函数,我完全可以携带输入。
应用推荐