If it is right, I'm going to print out the information but I'm also going to change that variable to true.
看如果它是对的,它是对的的话,我将会输出结果。
You should be able to maybe print out a blank copy of those notes from the website not for memorizing them, but now just understanding how the photoelectric effect works.
你们应该可以从网站上打印一份,这些笔记中的空白的纸张,不仅仅是为了记忆,而且现在要理解,光电效应是如何工作的。
So let's go ahead and introduce a couple other capabilities so that we can finally start writing programs that maybe print out charts or interact with the user, play games, or the like.
让我们继续来介绍其他几个功能,以便我们最终能开始写程序,那样可以打印图表或与用户交互,打游戏之类的。
But if it is not, it's going to print out a message here saying, you screwed up, somewhat politely, and it's going to go back around. So it'll just cycle until I get something of the right type.
但是输入不是浮点数的话,我这里就会显示一个消息说,你搞砸了,该稍微有点礼貌吧?,然后我们继续执行循环,一直到得到正确类型的输入。
I'm going to post it in a format which will be black and white and easy to print out so you don't have to worry about this.
我会把它做成黑白板式上传,方便同学打印,所以完全不用担心笔记问题
So you print out--you enter everything you've had for the day.
你输入这一天内摄入的所有食物
The second thing is, what do I print out if I actually don't get the right input in?
第二件事是我没得到,正确类型的输入时输出什么?
Let's check it out. I've written a little bit of a test script here, so if we test cell sort, and I've written this so that it's going to print out what the list is at the end of each round, OK.
我们来检查检查,我写了一个小测试脚本,我写这个脚本来测试单元排序,它能够打印出每一轮结束后,链表的是什么样子的。
OK, I can certainly print out strings, but I can actually add strings together, and just as you saw, I can multiply strings, you can kind of guess what this is going to do.
当然我可以显示字符串,但是其实我还可以令字符串相加,如你所见到的,我可以令字符串相乘,你们可以想想答案是什么。
Let's do a little Copy Paste down here so I can print out its size.
让我再做个复制粘贴,所以我能打印它的大小。
It means anybody using that little function get float doesn't have to worry about what's inside of it. So for example, I decide I want to change the message I print out, I don't have to change the function, I just pass in a different parameter.
这代表着用这个方法去获得浮点数,的任何人都不用担心具体的实现了,例如,如果我想改变下,显示的信息的话,我不必去改变方法,我传个不同的参数就可以了。
Right, so here's a little piece of code that's going to print out the smallest value of three.
好,那么这一小段代码,就是会显示出,三个值中最小的来。
One is, what's the thing I print out when I ask for the input?
第一件是当我要求输出的时候,我输出的内容?
It says, well I'm going to print out first and last just so you can see it, and then I say, gee 2 if last minus first is less than 2, that is, if there's no more than two elements left in the list, then I can just check those two elements and return the answer.
然后它计算了尾点和开始点的差,如果小于2的话,也就是说数组中的元素小于等于,我对这两个元素进行比较,然后返回结果就可以了,否则的话,我们就去寻找中值点,注意它是怎么实现的,首先这个指向一个列表的开头。
I then insist, okay, swap, and then I print out their values again.
我再强调,好的,交换好了,然后我再打印出,它们的值。
I go ahead and print out a small number.
我继续打印一个小数字。
And this is something you could print out to look at.
你们可以把这部分打印出来看。
I print out -- and this is only wrapping - because of the big font -- I print out, "I demand that you give me a positive integer."
我打印出来--这个字符相互覆盖了,因为用的是大字体-,我打印:“我需要你给我一个正整数“
We're checking the end test and incrementing, actually I was going to, I commented that out for a reason you'll see in a second, but I, normally I would keep this on, which would let me, at each step, see what it's doing. If I ran this, it would print out each step. Which is helping me make sure that it's incrementing the right way.
对不对?进行终结测试然后递增,实际上我要,因为某些你们,马上要明白的原因我把这里注释了,但是我通常会一直这么做,这样能让我看到每一步都做了什么,如果我运行这个程序,它会在每一步都,进行显示,这能帮助我让我确信程序是,在以正确的方式递增。
I can print out a string.
我可以显示一个字符串。
What I'm going to ask you to do is track what you're eating, and to go to a website that will allow you to enter all your eating, and then it will print out a dietary analysis of that.
我希望你们能记录每天吃的东西,然后到相关网站输入你的饮食记录,之后打印出饮食分析报告
Then at the end of the day what you'll get is something that looks like this which will be a whole day's worth of food intake and then this is what I'd like you to print out and then write about in your concept sheets.
一天结束后你就会得到,类似这样的一天食物摄入值,这就是我希望你们打印出来的,并且在你们观点报告中谈论的
It says, if I want to print out something I built in Cartesian form up here, says, again, I'm going to pass it in a pointer to the instance, that self thing, and then I'm going to return a string that I combine together with an open self and close paren, a comma in the middle, and getting the x-value and the y-value and converting them into strings before I put the whole thing together.
这不仅仅是个列表,它是怎么来做的?,流程是:如果我想要返回,一些已经在笛卡尔模式下建好的值,好,再说一遍,我首先要传入一个,指向实例的指针,也就是,然后我会返回一个,由开括号,闭括号,中间的一个逗号,以及提前转换为字符串格式的。
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的数值,可能你们需要两行或者三行的代码,但是最终的目标需要你自己独自尝试。
But that little short hand there is doing exactly the same thing. It is adding that value into some digits and putting it back or signing it back into some digits. And I'll walk through that loop and when I'm done I can print out the total thing does. And if I do that, I get out what I would expect.
加上得到的这个数的,但是这个缩写声明其实是进行了同样的操作,它把我们得到的这个数加到一个数上面去,然后用和对这个数进行了重新赋值,在循环中会去遍历字符串,当完成循环后,程序会显示数字的总和,如果我运行,这个程序的话,我会得到我期待的结果。
All right, it's so if I looked at it, sorry, IF x is less than y, THEN check to see IF x is less than z, and if that's true, print out x is the smallest.
好,代码是这样的,对不起,是不是x比y小,然后去看看是不是x比z小,如果都为真的话,显示x为最小值。
So don't underestimate the value for the next week or two of just inserting printf statements into your code temporarily just to print out what the value of some variable is, or some expression is, so that you can just do a sanity check.
所以不要低估下一两周的重要性,虽然我们只将“printf“语句暂时地植入到,我们的代码中,只是用来打印一些,变量或表达式的值,所以你们提醒一下自己。
Remember last time, we wrote this simple piece of code to print out even or odd. If, you know, x, 1 it was in fact, even or odd. So let me show you what a flow chart for that would look like, because I want to make a comparison point here.
这就像这里有一些脚蹼一样,首先进行测试,然后把球这样放来让ANS加,然后回来继续测试,最终跳出循环然后打印答案。
It's going to print out even or odd, depending on whether the value I put in, which is x in this case, is even or odd.
它会打印奇数或者偶数,这取决于我输入的值,也就是这个例子中的x,是奇数还是偶数。
应用推荐