background top icon
background center wave icon
background filled rhombus icon
background two lines icon
background stroke rhombus icon

Download "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]"

input logo icon
Video tags
|

Video tags

основы программирования
cs50
cs50 на русском
cs50 лекция 5
Week 2
гарвард
баги
Subtitles
|

Subtitles

subtitles menu arrow
  • ruRussian
Download
00:00:17
welcome to Harvard for the C course with
00:00:21
fifty,
00:00:24
that's all I'm Swifty and we're starting the second
00:00:27
week of classes, let's dive
00:00:30
into the world of the gods, so to speak,
00:00:31
here we have a development environment with fifty and I
00:00:34
prepared the program in advance because it
00:00:39
was a spoiler and so here I have
00:00:42
there is a very simple program in store,
00:00:44
if you scroll you can see that most of it
00:00:46
consists of comments, but from lines 13 to
00:00:49
17 this program is syntactically and
00:00:52
probably that is, if I run and and we are
00:00:54
compiled, it will be executed, but it contains
00:00:56
a baguette, we scold above in the comments it is
00:00:58
stated that the program should print
00:01:00
10 stars but she doesn’t do this as
00:01:04
per your experience and
00:01:05
soon you will have enough experience
00:01:07
can you logically justify what the
00:01:10
bugs are here
00:01:11
yes she counts from 0 to 10
00:01:14
this is 11 steps and yes she starts from
00:01:19
0 the hunt reaches the moment equal 10 catch
00:01:22
and of course this is the 11th operation by default in
00:01:26
most programming languages, counting
00:01:27
starts from 0 and continues to the
00:01:30
value that was intended but not including
00:01:32
it, this is a very important point that you
00:01:34
need to get used to, it will transfer scratch, which was invented for
00:01:37
non-programmers and even higher for children,
00:01:39
designed this way that counting
00:01:41
starts from one and this is normal, you
00:01:44
can very well start from one if it’s
00:01:46
more convenient for you and count up to 10 inclusive,
00:01:48
but you will soon understand this week and
00:01:52
then these that programming has so many
00:01:54
moments Finn when 0 by default
00:01:56
is considered the first digit of the game pony what It
00:01:58
will be easier for you to get used to counting from
00:02:01
zero to the value you need, I’m a fan
00:02:04
of the court, so we fixed it, we changed
00:02:07
less or equal
00:02:08
and just less, let’s now look
00:02:10
at the second example in the comments of this
00:02:12
program it is also stated that it should
00:02:14
display a dozen stars, but it doesn’t it
00:02:16
turns out that in general there is a bug here,
00:02:21
sorry, let’s for clarity, let’s give 10
00:02:23
stars for one line per pair, it
00:02:25
doesn’t show them dream with facts, we say so
00:02:28
let’s compile and and because from the
00:02:29
description everything is not so obvious
00:02:31
by us votes and who and go to the source
00:02:34
directory of my bugs 1 point slash bugs one
00:02:37
gods of war and so 11 stars were displayed,
00:02:41
this is bad, besides they are all in one
00:02:44
line, in general, the point here is that the
00:02:47
cycle is not highlighted with separate curly
00:02:49
braces, I'm Shindo,
00:02:52
if you noticed, I already
00:02:54
mentioned this in passing about the elite, although everything
00:02:57
looks beautiful structured like a
00:02:59
scratch sistine, as if construction 16 and 17
00:03:02
are written inside a loop, but this is not so
00:03:04
and the computer does not know and does not see spaces,
00:03:06
spaces are for us for beauty,
00:03:08
the computer understands curly braces, which will
00:03:10
fix our problem
00:03:12
if we put curly braces here and the
00:03:15
problem will be solved because their compiler
00:03:17
will understand that I want to execute two lines of
00:03:20
code over and over again oceans legend
00:03:23
game what the point is here is clear but I
00:03:26
definitely always need curly braces
00:03:29
although it’s better to accustom yourself to them
00:03:31
despite the fact that they add two
00:03:34
extra characters to the year why yes this is great an
00:03:38
alternative especially if at first
00:03:40
glance you can’t figure out what it is,
00:03:43
of course we can do two in one and thereby
00:03:46
avoid the problem altogether, and that’s
00:03:48
right, but still in our example,
00:03:51
why did the tank appear, why were all the sprockets
00:03:53
in one line, yes, it looks like if
00:03:57
we have one line of code, then it’s possible without
00:03:59
them, this is exactly what people agreed on, a
00:04:03
person reads tediously and tediously and
00:04:05
leave curly braces everywhere if you
00:04:07
need to execute just one line of code,
00:04:09
so people decided that this is my
00:04:11
people if you want to cram the entire
00:04:13
loop into one line then this is possible in the end
00:04:15
. a
00:04:16
comma but no curly braces, maybe
00:04:19
only one line, the
00:04:21
style guide will point this out to you
00:04:23
and you'll see that it's worth
00:04:25
getting into this habit, at
00:04:27
least until you feel ready to
00:04:29
break away from these conventions and work in
00:04:31
your own style for now. you won’t be confident in
00:04:33
yourself a little later we’ll talk more about style
00:04:36
now let’s open another program donkeys
00:04:38
of course first we’ll fix this top ten let’s
00:04:40
continue and I’ll quickly write a simple
00:04:43
program which I’ll call which I’ll call for
00:04:48
example a bow.
00:04:50
the heart is in the same place. I will have strength in the
00:04:53
cloud as standard.
00:04:55
ich in pink white and let's again
00:04:58
make a loop int age- for a ent is
00:05:02
equal to zero oh less than 50 + + key
00:05:05
and here we will register the printer further we have oh
00:05:09
new line semicolon and it will display
00:05:12
all the numbers of the 1st row 50 some nod
00:05:18
some no in what already Pak what an
00:05:20
elementary mistake I made before they
00:05:24
look like everything is correct but the call is
00:05:26
just a call to the ask symbol so it is
00:05:28
printed literally oh but if I want to
00:05:31
get the value of the placeholder, otherwise I have to
00:05:33
do this and then the
00:05:34
value will be displayed sequentially,
00:05:37
otherwise I have there will just be 50 characters oh
00:05:40
on the screen, so let’s run this loop
00:05:43
and here we have numbers up to 49 inclusive, and
00:05:46
if we scroll back we’ll see
00:05:48
0 at the beginning, but what if we mess it up a little and
00:05:51
do it like this, well, suddenly I didn’t think what
00:05:55
this program would logically do.
00:05:58
shark I'm nothing nothing why a and equal
00:06:03
means the conditions will not be met until the
00:06:07
correct syntax code ohc
00:06:09
compiles will run but will not do
00:06:11
anything useful because I assigned the
00:06:14
value 0 then check a and more than 50
00:06:17
the answer is no and the loop will never be executed
00:06:20
what if we make it even crazier what if
00:06:24
oh is equal to zero and here is a while-loop
00:06:27
with other conditions we make a bunch of notes from
00:06:30
individuals and from as long as i is greater than
00:06:32
or equal to zero we continue and save the file
00:06:37
file because my club annotation can be
00:06:41
launched what will happen now with the
00:06:44
while-loop until an endless loop an
00:06:47
endless loop day to alba why
00:06:50
because always 0 to ai is declared
00:06:54
zero soil of course oh will always be
00:06:56
greater than or equal to zero
00:06:58
now let's see what
00:07:00
infinity looks like a couple of times teachers
00:07:02
wondered what to do if the loop is
00:07:04
endless when in value kontrol c
00:07:08
poison kontrol c will help unfortunately we have
00:07:11
already lost pour millions so
00:07:13
the computer was a little stunned so it
00:07:16
hung up a little, but if you
00:07:18
press control c several times on your laptop
00:07:20
or computer at once,
00:07:21
the program will end, and if not, then I
00:07:23
’ll show you more ways to force the
00:07:26
program to end in Windows or
00:07:28
Macintosh heat if necessary, let’s try
00:07:31
something else - let's increase it, will the loop be
00:07:35
infinite, let's run it, you see what's
00:07:40
happening, it's also an infinite loop, but there is a
00:07:45
question, it will forever
00:07:46
print the numbers no no no, why did I
00:07:53
hear from here, no, anyone, there aren't
00:07:57
enough bits to continue infinitely
00:07:58
true, so I don't have enough bits that
00:08:01
will just stop at some
00:08:04
point we will complete it completes the cycle
00:08:08
but why what will happen when it
00:08:10
gets closer to the
00:08:11
wives two yes it will jump to
00:08:14
negative numbers to a negative
00:08:15
number or if we set only
00:08:18
positive then on me probably
00:08:20
remember we said that if exceed the
00:08:22
number of bits, then the volume of an
00:08:24
integer or other data type will overflow and
00:08:25
there will be a cyclic return, possibly to
00:08:27
negative numbers, or if you set the
00:08:30
value to be only
00:08:31
positive, this can be done, although in
00:08:33
our example this is not the case, it will return
00:08:35
to zero, and yes, in our case,
00:08:37
negative numbers be after which the cycle
00:08:39
will end because it will no longer be
00:08:41
greater than or equal to zero if it is
00:08:43
negative how long will we have to
00:08:45
wait now we have what about 2
00:08:47
million and should reach two
00:08:51
billion so we need to wait until we
00:08:54
get to them but we can speed up the
00:08:56
process maybe Let's see if it's possible to
00:08:59
pause,
00:09:00
come on, even the menu is slow, or oh well, let's
00:09:07
come back to this later, it's time for the hell
00:09:10
puppies, it's time to make an announcement,
00:09:12
you can take part in the marathon in
00:09:15
Warhead, which is sponsored by our friends
00:09:17
from Spruce, by the way, there will be graduate students, teachers of
00:09:20
Spruce, and somehow international
00:09:22
developer forum taking place at Yale,
00:09:24
which brings together about one and a half thousand
00:09:26
hackers and computer scientists from all over the world,
00:09:28
if you are interested, go to the website,
00:09:30
the information is on the slides of today's
00:09:32
lecture, their website is lifehack dot org and a
00:09:35
couple more announcements, group classes
00:09:37
will begin next week here in
00:09:38
New Haven by On weekends you will receive a
00:09:40
message by e-mail; organizing
00:09:42
all this requires time for this
00:09:44
number of people and all sorts of movements; the
00:09:46
schedule of graduate students; teachers are also
00:09:48
still cut off; keep an eye on the mailing;
00:09:50
if necessary, then Perry
00:09:52
sign up stage. si aspect. no,
00:09:55
even if you don’t miss lectures,
00:09:57
you know that almost all the materials that
00:09:59
we use in classes are available on
00:10:01
this site, so if you want to
00:10:03
refresh the material or get ahead of yourself,
00:10:05
if you can’t attend
00:10:07
next time, you can refer to the
00:10:08
slides for tasks with definitions and there’s a
00:10:11
lot more
00:10:13
stuff there day today tomorrow Wednesday and
00:10:15
Thursday see the schedule on the website
00:10:17
also discussions with fifty are launched
00:10:20
so if you have questions about the course
00:10:22
or when solving problems, keep in mind that
00:10:24
you don’t have to pull your neighbor,
00:10:26
especially if there is no neighbor, you can
00:10:29
contact us or your classmates
00:10:31
online through fifty discos this such a
00:10:34
platform for discussions and by perhaps it is
00:10:36
best to start with it when you have
00:10:38
questions, especially when there is no consultation
00:10:41
to get on this day to the altar of the autumn experience from
00:10:44
this week in our restaurant fire and
00:10:45
ice and in the sector in sniff blame lunches will begin
00:10:49
follow the site to accept the
00:10:50
invitation and come if it doesn’t
00:10:53
work out this week, then we will be there
00:10:55
almost every Friday during the semester,
00:10:57
and now regarding the assessments, 1 problem book
00:10:59
comes out this week, then the second, and
00:11:01
so on, how do we evaluate the quality of
00:11:04
solving problems on the floor and did with fifty out of
00:11:07
4 criteria the volume then there is a number of
00:11:10
tasks that you have completed, roughly speaking,
00:11:12
this is the degree of your effort, so we understand
00:11:15
that if you solve half of the problem book
00:11:17
or the whole
00:11:18
thing, you have a chance to get high
00:11:21
marks if you have worked through each section of the
00:11:23
problem book, so keep this in mind and then
00:11:25
such Tallinn my correctness is direct
00:11:28
sense, does your code work in accordance with
00:11:30
the task, does it do what it should,
00:11:32
this is not yet known in the
00:11:34
specification section of the problem book number one, the
00:11:36
command check Ferdy is described which
00:11:38
will help check whether
00:11:41
your program is working correctly or not, at least
00:11:43
we will evaluate it based on checks
00:11:46
check fifty program structure is more
00:11:49
subjective, we look at how well
00:11:51
your code is written, this comes with
00:11:53
time and here we will comment in more detail on
00:11:55
the quality of your work and
00:11:57
substructures. I mean, for example, that
00:11:59
when solving a problem you will need to
00:12:02
do something in a loop and here you have
00:12:03
345 nested
00:12:06
loops for pe wild will appear. This code should
00:12:09
confuse you because this is not a very
00:12:10
well-thought-out structure in lectures and at home
00:12:13
you will gradually learn to feel where it is
00:12:15
beautiful and where it is not, although it may be
00:12:17
correct, but it is built so-so, it’s like
00:12:20
writing an essay, you can get the grammar
00:12:22
correct compose sentences from words but
00:12:24
at the end you get an incoherent,
00:12:26
convincing text, so by analogy with the
00:12:28
text you can say whether the program is well or poorly
00:12:29
constructed, style is also very
00:12:32
subjective, here we expect at least
00:12:33
consistency, and the beauty of your
00:12:36
code is everything clear, or are the variables
00:12:38
named correctly? but all or brackets
00:12:40
including curly ones are aligned all swifts there is a
00:12:43
style guide you can
00:12:44
look at it if you are confident in yourself you do
00:12:46
n’t have to follow these rules but
00:12:49
only if everything is logical and consistent for you
00:12:51
if everything is too fast
00:12:53
don’t worry problem books and in group
00:12:55
classes about there will be more detail on all of this,
00:12:57
but in general we all have just
00:12:59
a few ratings, the scale is usually from 1 to 3
00:13:02
or from 1 to 5,
00:13:03
take it literally, I won’t get tired of
00:13:06
repeating this to you, three is good, although
00:13:08
mathematically, three out of five years, about 60
00:13:11
percent and leads with a minus, but with us three
00:13:13
means good in general, most
00:13:16
students by the beginning of the semester will
00:13:17
receive 2 3 and 4 points of A's usually
00:13:20
few ones also in general usually starts
00:13:23
from this point on the curve of perspective
00:13:25
accelerates and demonstrates progress
00:13:27
so please do not think that
00:13:29
a C is 60 percent it is much broader
00:13:31
the formula by which we calculate the assessment
00:13:34
can be decomposed so that correctness has
00:13:36
the greatest weight; the structure of the program is a little
00:13:39
less; the style is even less; the formula
00:13:41
takes into account the amount of time needed
00:13:43
to fulfill each of the requirements and
00:13:45
let it be; it is very simple; it means it
00:13:47
is done quickly, but here it is easy to fall into
00:13:49
rudders; correctness usually takes
00:13:50
maximum time fiddling with gods sometimes
00:13:53
takes an hour or two
00:13:54
when grading all this
00:13:55
is taken into account for now serious
00:13:57
good or bad but now fifty
00:13:59
is different in that we are perhaps more often
00:14:01
faced with the problem of scientific
00:14:03
integrity than other courses and as a
00:14:05
result because of this we
00:14:07
expel more every year as far as I know
00:14:08
students for disciplinary reasons
00:14:10
so let's briefly talk straight
00:14:12
about what is happening at all fifty what
00:14:15
you can do and what you should
00:14:16
remember fouls here shows the number of
00:14:18
cases the introduction of the administrative
00:14:20
council is the seventh year since I have
00:14:22
been teaching this course administrative and now the
00:14:24
honorary council is the disciplinary body of
00:14:26
Harvard that deals with the case when
00:14:28
students do something unacceptable and not
00:14:31
in any pattern from year to year in
00:14:33
different ways, but in general, here you can see
00:14:34
the number of cases, the number of
00:14:37
students affected also jumps, just last
00:14:39
year, 29 Harvard students talked to the
00:14:42
commission 29, so to speak of the current and
00:14:45
two former students who did
00:14:46
not cooperate in a completely appropriate
00:14:48
way, and here the percentage is usually about
00:14:52
three percent of the stream, unfortunately,
00:14:54
act in a similar way last
00:14:56
year, three and a half percent of the
00:14:57
student body had to
00:14:59
get acquainted with the commission, so to speak, well, that’s
00:15:02
what it all means and what Specifically, we
00:15:04
do, as a computer scientist, some software tools are available to us,
00:15:07
and frankly
00:15:09
speaking, it’s quite easy for us to
00:15:10
cross-compare the works
00:15:12
presented this year with all the
00:15:14
works of the last eight years, for this there
00:15:16
are programs,
00:15:17
of course, a person decides whether or
00:15:20
not this or that case is a violation, but the
00:15:22
software tools are great they help and,
00:15:24
to be honest, I think that’s why we
00:15:26
had
00:15:27
such large numbers from Fichte, not because
00:15:29
the students of our course are less honest than
00:15:32
students of other courses, but because
00:15:33
we have technical means for
00:15:35
screening out
00:15:37
almost fitness bones at the first stage, we are monitoring all this
00:15:39
in the interests the majority of students
00:15:41
and their work done and
00:15:44
labor expended oh all the memory and orey 1st grade, the
00:15:47
quality of the course is based on scientific
00:15:49
honesty and although there are many paragraphs
00:15:51
with a long list of points, I hope to
00:15:53
actually read them, but it all comes down to
00:15:55
this, be reasonable, the best recipe for
00:15:57
success in the course is that the main
00:15:59
backbone of
00:16:00
the work, let the work pressured by you should be yours,
00:16:02
almost all cases when students were
00:16:04
subjected to disciplinary action
00:16:06
came down to the fact that one student,
00:16:08
usually late at night, showed his code to
00:16:10
another student who
00:16:12
then used this treasure in its entirety or most of it,
00:16:14
causing his work to experience
00:16:16
difficulties okay, I will repeat following the
00:16:19
advice written on the pieces of paper that
00:16:21
you gave to those who attended the consultations
00:16:23
last week, you can at any time
00:16:25
and we recommend that you discuss
00:16:27
problems with your classmates on you always
00:16:29
remember the rule when you ask for help you
00:16:32
can show your code to others but you
00:16:34
should not spy on other people's codes,
00:16:36
in other words, for example, I'm struggling with a task, I'm
00:16:39
sitting in cafeterias, not libraries or
00:16:40
classrooms, trying to find an error,
00:16:42
of course, I can show my code on the
00:16:44
screen to someone who is sitting next to me, including
00:16:46
a classmate, but if my classmate
00:16:48
suggests in response, look how I
00:16:51
did, then this is already going beyond the line and
00:16:54
I dare to suggest that for
00:16:55
most it is quite obvious where this
00:16:57
line is. You will also find details in
00:17:00
the manual
00:17:02
and one of the most controversial points is the
00:17:04
course of the axis with fifty, which I will talk about in
00:17:07
conclusion, this is the so-called point of
00:17:09
repentance, the fact is that over the past
00:17:12
eight years, it was noticed that most
00:17:14
cases of deception were the result of an
00:17:16
incorrectly made
00:17:17
late-night decision of salts as
00:17:19
a result of stress as a result of the fact that there
00:17:21
was no time to eat sleep too
00:17:23
many tasks deadlines responsibilities to
00:17:25
overcome a stressful state at two three
00:17:27
four o'clock in the morning and the ghost of raising
00:17:30
deadlines father copper in these circumstances,
00:17:31
most students make bad
00:17:33
decisions that they may regret the
00:17:35
next morning or even a minute later,
00:17:38
but until last year there was no mechanism
00:17:40
for such students to
00:17:42
confess everything without fear of expelling from
00:17:44
college, so last year we
00:17:47
introduced this clause of repentance which
00:17:49
says that if within 72 hours, that
00:17:52
is, exactly from the moment of violating
00:17:53
any course norm, you come to
00:17:55
one of the managers, then we will
00:17:57
discuss it and of course there will still be some kind of
00:17:59
penalty. It’s not true that nothing
00:18:01
will happen at all, usually it’s something like
00:18:03
cancellation of the results of solving problems
00:18:05
or something similar, but at
00:18:07
least we will settle everything internally and
00:18:09
will not take it further where the penalties
00:18:11
can be much more serious and my
00:18:13
opinion about this innovation over the past
00:18:16
8 already 9 years since I have been teaching this course as I have
00:18:18
encountered various aspects and
00:18:20
problems of scientific integrity and I see from the
00:18:22
numbers that nothing even a speech like mine
00:18:25
now particularly changes the situation,
00:18:28
so this was definitely a better
00:18:29
pedagogical decision to conduct ses over the
00:18:31
past 8 years, last year
00:18:33
19 students addressed this point, seven
00:18:36
of them we did not use no penalties,
00:18:38
considering that they were not guilty,
00:18:40
it turned out that they did not violate anything,
00:18:43
but the conversation was still useful for 11
00:18:45
students, we reset the results of one
00:18:48
student, asked to redo the assignments, and
00:18:50
but the most interesting thing in these nineteen
00:18:52
conversations, because they went a little
00:18:54
beyond what I expected, was that that
00:18:56
every ten minutes or an hour talked
00:18:59
about problems with family with friends with a
00:19:01
state of mind and we then
00:19:03
involved the deans of friends in their solution, and
00:19:05
so on, it was one of the most
00:19:07
productive pastimes and a very
00:19:10
timely intervention, it is worth
00:19:12
saying that this did not affect the overall
00:19:14
statistics fraud give I will assume
00:19:16
that this category of students was
00:19:17
not previously identified by us and did not fall into
00:19:20
our field of visibility for purchase, this is a
00:19:22
wonderful achievement they want the reasons for them
00:19:24
were more than unfavorable
00:19:27
circumstances, so don’t
00:19:29
forget if suddenly one
00:19:30
late at night you make the wrong
00:19:32
decision, you can get help
00:19:34
if you admit it and come to us, it
00:19:36
will be useful and you can leave all
00:19:39
this in the last field and Haida stummick
00:19:41
is so done with the advertisements and
00:19:43
to positively end this conversation I will
00:19:45
finally show you the puppies, they will somehow
00:19:48
relieve the tension from the force,
00:19:52
unfortunately the puppies fell asleep
00:19:53
but in general they were supposed to shake you up
00:19:55
and calm you down after such a difficult topic,
00:19:57
but it seems that I felt the puppies and what
00:20:02
if you go to the Swiftie website, hearing in the
00:20:05
sand, you can look at the puppies
00:20:07
all day long, especially at 2 3 and 4 o'clock in the morning
00:20:11
to relieve stress
00:20:12
slash poppies well ok, fun, now let’s
00:20:19
try to get back to programming,
00:20:21
remember last time we looked at not
00:20:23
only main, which is the default function,
00:20:25
similar to a pressed green
00:20:27
flag, but we also started writing our own
00:20:29
functions, they weren’t particularly large in
00:20:32
content, you’ll come across much
00:20:34
more complex functions, perhaps in
00:20:36
problem book 23 exactly in the fourth and gave them
00:20:39
to the brush while most of the commands in your
00:20:41
programs
00:20:42
from the problem book are one if not all can be
00:20:44
entirely contained in mine if you have
00:20:47
510 in your program even twenty lines it
00:20:50
definitely makes sense to write them in the
00:20:52
main function and not complicate your code
00:20:54
but today further we will practice
00:20:57
several good techniques so that as
00:20:59
your code becomes more complex and when you
00:21:02
solve an increasingly difficult and more
00:21:04
interesting problem, you will have
00:21:06
developed ways to create elegant
00:21:09
circuits Gusinsky succeeded with a toothy
00:21:11
let's return to the program from last
00:21:13
week
00:21:14
Marlos function 0 background. sedation pay
00:21:19
attention it includes two functions in
00:21:22
typhon main and
00:21:24
and print name let's remember
00:21:27
or guess why on the twenty-eighth
00:21:30
line we added a function called
00:21:33
printname an example of what this is in
00:21:36
essence
00:21:40
I hear whispers that before
00:21:44
functional decomposition this terrible
00:21:46
word means breaking a program into
00:21:47
components parts and then these parts
00:21:49
are assembled into whole ones. Now I may say
00:21:53
another tricky word, but
00:21:55
this is probably one of the best examples of what
00:21:57
is called abstraction.
00:22:05
with
00:22:07
it, the solutions become more
00:22:08
intuitive and therefore more understandable,
00:22:10
valuable for other tasks
00:22:12
what I mean by you canoe is perhaps
00:22:15
much more convenient to read the program and
00:22:17
shortened to the maximum when in line
00:22:20
22 you see that a function called printname is called
00:22:24
and the name already says what it
00:22:27
does 5 Fokin obviously it accepts
00:22:29
input data inside brackets and obviously
00:22:32
doing something, apparently prints the name salons
00:22:35
and although we could have done exactly the
00:22:38
same as a week ago, take this line of
00:22:40
code, remove this
00:22:41
and all this without us abstracting from the
00:22:43
procedure for outputting the name ohina bhante nina
00:22:46
I don’t care whether you used a printer
00:22:49
or a printer or a backslash and all these
00:22:52
unnecessary details I, as a programmer,
00:22:54
only care about getting the name out and the
00:22:57
easiest way to do this is by calling the
00:22:59
print in function and this is one of the reasons to do
00:23:01
something like this so that the cat is easier to
00:23:03
read, edit and he described himself the
00:23:07
feeling now let's look at
00:23:08
another example of a function one
00:23:10
this example is even more interesting because
00:23:13
here I want to get not just an
00:23:15
integer, rather I need a positive one but
00:23:17
to get a positive number I
00:23:19
will have to perform many actions
00:23:21
they are no longer just a call to one line like
00:23:23
printname
00:23:24
because of which it turned out not so interesting
00:23:26
to get positive integers by
00:23:28
logic I’ll
00:23:29
scroll down to hide what
00:23:31
we need to do all the tools that we
00:23:35
have this function types printer from the
00:23:37
standard library from the library ses
00:23:39
fifty get in getfloat getlonglong get
00:23:41
string then we now need get ya mind
00:23:43
if the only tool that
00:23:45
is in our set and tagged game,
00:23:47
how can we use it to get a
00:23:48
positive number, create a loop and
00:23:51
check whether the entered number is
00:23:53
positive, that’s great, and another
00:23:56
tool that we mastered a week or
00:23:58
two ago
00:23:59
is creating cycles if we use a
00:24:01
while loop
00:24:02
or do while or form be any of
00:24:04
them suits us then we can
00:24:06
get a positive number using
00:24:08
only the get int function we will call and
00:24:11
torture the user again and again until
00:24:13
he finally gives us what we need and
00:24:16
now abstract the process of
00:24:18
getting positive numbers inside the
00:24:20
get function positive and seems
00:24:22
appropriate because look
00:24:24
here,
00:24:25
more than 10 lines of code are required to
00:24:27
get a positive number and I
00:24:29
don’t need to know how you implement it,
00:24:31
the main thing is that you implement all these details, I
00:24:34
hid functions called no
00:24:36
positive and we just looked at the do while loop
00:24:39
last week its
00:24:40
syntax is declared and an
00:24:43
instruction for the user is printed called
00:24:45
get int again and again and again the
00:24:46
conditions are checked until the user
00:24:48
gives up serials and now a
00:24:51
common sense test can be someone who is familiar
00:24:54
with programming knows why n is
00:24:56
declared and like outside the loop do
00:24:59
wild why is it an article 29 they 33
00:25:03
for example, pine finds
00:25:05
because if you declare it outside the
00:25:08
loop, the scope and action will be wider, it will be
00:25:11
good if you declare it inside the loop, the
00:25:14
rest of the program will not know about it,
00:25:17
that’s what I fatin, in other words, it’s in the
00:25:20
scope of action, that is, in the environment
00:25:21
where it exists or is used
00:25:23
variable i guess you is filled
00:25:27
there is a rule when declaring or creating
00:25:29
a variable always remember that it will be
00:25:31
used only within the boundaries of the
00:25:33
nearest curly braces
00:25:34
smile who does this mean if I now
00:25:38
remove all this and make it seem simpler
00:25:42
because the thirty-second line
00:25:44
seems to be clearer to you here and a variable and a
00:25:47
function and the assignment of one to the other,
00:25:50
however, the catch is now in the
00:25:52
scope, because it can only be used
00:25:55
within a loop in lines 31 and 32,
00:25:58
but where is it not possible
00:25:59
in which lines up to 35, definitely not in 35
00:26:05
you can also, and even in 34 it won’t work anymore
00:26:10
because it behind the curly brackets,
00:26:11
so what will happen, let's look at mine, you can
00:26:14
try to guess if you want, and we'll check
00:26:16
what the compiler will tell us,
00:26:18
opening the source directory, I run the
00:26:20
program, damn it, absolutely, the
00:26:27
program, by the way, is wonderful, but what
00:26:29
happened here looks very strange, so I
00:26:32
typed main function 1 and that's what
00:26:35
followed: the compiler gave us
00:26:36
a warning with them, we'll look into them in more detail
00:26:38
later, always pay
00:26:40
attention to the first error because it can
00:26:43
affect all the following lines, it's
00:26:44
pointlessly quiet here we have an error hidden
00:26:47
in the function 1.7 program, the thirty-
00:26:50
second line in the column, that is, in the
00:26:53
symbol under number 13,
00:26:54
so you find and parse the description of the
00:26:57
error, now we look for line number 32
00:27:00
and here it was initially open,
00:27:02
an error is obtained in an unused
00:27:04
variable, but
00:27:06
I used it, but the
00:27:08
compiler is confused because it exists
00:27:10
only within this area and therefore
00:27:12
cannot be used here or here and
00:27:14
the compiler absolutely doesn’t care how I
00:27:16
explain it, the variables don’t function
00:27:18
as within these boundaries, so we need to
00:27:21
increase the area here 2 and as it
00:27:23
was originally int n and even if it does
00:27:26
n’t look so elegant,
00:27:27
maybe an extra line appears,
00:27:29
but everything is in within the scope of it one more time
00:27:32
and so main function one great now let’s
00:27:35
run the program let the values ​​be
00:27:37
minus 10 minus 101 everything works but
00:27:42
we have one more solution knows what one
00:27:44
let’s outplay everyone suppose I don’t
00:27:47
know where this will be needed but what will I do I’m
00:27:50
announcing the very beginning here is what
00:27:54
this will give as it is considered
00:27:57
before the variable will be everywhere, well, yes, I
00:28:03
used a global variable, if
00:28:06
you place the variable outside the boundaries of all
00:28:08
functions, this is permissible and the code will
00:28:10
compile and n will be available not
00:28:12
only for get by visiting and but also for main,
00:28:14
so this is already a reason to worry
00:28:16
after all, main already exists n we’ll come back to this later,
00:28:19
but this is not good from the point of view of the
00:28:21
code structure if you decide, oh okay,
00:28:24
put it here somehow, it compiles,
00:28:26
you know, this is far from a solution, better
00:28:29
try to determine the smallest
00:28:31
possible area for your change, as
00:28:33
we had at the
00:28:34
very beginning that is, they are not here, and here’s
00:28:36
another thing: if you have a variable with
00:28:38
the same names, then in the C language it
00:28:40
works as follows: let them
00:28:42
always, but in this case everything will work out in the
00:28:44
twenty-second line, local, it
00:28:46
will overlap the global top 6, this does not
00:28:48
function within main and global
00:28:51
entering shod force get positive in let
00:28:54
's work it out, it looks like so far in a nutshell
00:28:57
for the most curious and so we would have dealt with it
00:28:59
now let's deal with the
00:29:01
other two pieces of code before we move on
00:29:03
to its ending get positive winked to the left
00:29:06
of it we have another word here int
00:29:09
why it’s here, what do you think,
00:29:11
before this we
00:29:12
mostly saw here void yeah, this is the type of the
00:29:15
requested variable, and the tide is
00:29:17
just not a variable, but the value of
00:29:19
which I want to receive in response, and
00:29:21
this is understandable on an intuitive level, but
00:29:23
if you need an integer positive,
00:29:25
then you want that a function like our
00:29:27
volunteer last week brought you a
00:29:29
piece of paper with a number on it
00:29:31
so the return type of this
00:29:33
function is guide positive land receiving a
00:29:34
positive integer if we don’t
00:29:37
need to return anything in response we write and
00:29:39
howls if we need to be in response a string we
00:29:41
write string
00:29:42
if we need to get a
00:29:43
floating point number, but here the
00:29:45
logical one is only suitable, and after all,
00:29:47
I need an integer, let me limit
00:29:49
it to positive values,
00:29:51
but what does white in
00:29:53
parentheses mean, what do
00:29:54
parentheses mean in general, yes, it means the pound
00:29:56
does not accept, it means the function does not accept
00:29:59
that some kind of input data is a
00:30:02
volt, that is, the empty space in
00:30:04
parentheses is a sign that I don’t need
00:30:06
the data, I decide it myself with a question and you
00:30:07
really
00:30:10
don’t need to say anything about the function get positive screw, just call
00:30:12
you get positive in and it will work,
00:30:14
however there is more one trick that I
00:30:17
used all the way so that the cat
00:30:18
compiles correctly, pay attention
00:30:20
and get positive and white on line 27
00:30:24
and also here is a coincidence, the entire set
00:30:26
is repeated in line 16 for the purity of the
00:30:29
experiment, let's make the repetition
00:30:31
absolute
00:30:32
and here we also added a prototype, just
00:30:36
a line with a comment what happens if
00:30:38
I I’ll delete all this and restart the program
00:30:41
make panshin one enter oh a
00:30:47
minute where is this now now
00:30:53
moment function one there is excellent not
00:30:57
saved just here I think there’s
00:30:58
a small bug I can’t see the name of
00:31:00
the bookmark oh well that’s not a drive so what
00:31:02
happened is an implicit
00:31:04
phenomenon function get positive young didn’t
00:31:06
work all 99 again it’s not clear what
00:31:09
this tells us the thing is that the C language is
00:31:11
not very smart
00:31:12
it’s just a programming language or
00:31:14
rather the compiler is stupid it only knows
00:31:17
what you taught it and generally knows
00:31:19
something only when you tell it teach in other
00:31:22
words, I am now trying to call the
00:31:24
getpositiveint function in the body of the main function,
00:31:26
but the compiler does not find this function
00:31:28
until line 26, quite logically, it
00:31:31
throws an error as soon as it gets to
00:31:33
line number 17, stating that the function is
00:31:36
declared implicitly, which in human
00:31:38
language means
00:31:39
I don’t understand what yet such get positive
00:31:41
and other java languages ​​Python or Ruby can
00:31:45
look ahead themselves are not able to setup
00:31:47
we have one of two years left or the fact is
00:31:50
that get positive young is not visible
00:31:52
earlier when we just move it and I above the
00:31:54
problem is solved
00:31:55
however in general it is technically better after all
00:31:57
place the main function at the very beginning
00:32:00
so that the person reading your code can
00:32:03
understand what the program does
00:32:05
9th place main main function for me in
00:32:07
the middle or at the end
00:32:09
at the beginning somewhere over 200 this solution is not
00:32:11
ideal and you may find yourself in a
00:32:13
situation where one function calls a
00:32:15
second and a third and it turns out that
00:32:17
none of them can be forward here to
00:32:19
the other, following the logic here it is impossible to
00:32:22
untangle such a knot, you can only
00:32:24
take the details of the function in one way, let’s say, that is, the
00:32:27
first line where it is declared and
00:32:29
move the hopper to the beginning
00:32:31
but without curly braces, just a
00:32:33
semicolon such a small hint at future
00:32:35
events, by the way, all this time we have
00:32:38
been watching the standard floor.
00:32:40
speech and disappeared fifty. speech, these are
00:32:43
also prototypes that are located in certain
00:32:46
files with the extension .
00:32:48
Let's get back to this later,
00:32:50
so if your program has several
00:32:53
functions in addition to the main site, you almost
00:32:55
by default need to
00:32:57
present them on the first line with a
00:32:59
semicolon at the end, and at the very beginning of
00:33:01
the file like this, the amount of new information
00:33:04
may not be enough for anyone who has questions, well
00:33:09
ok let's move on remember the program
00:33:11
about cough fits perfectly wonderful to
00:33:16
cough this version of the program is in C and that time
00:33:18
we analyzed it using the example of Krechi, it
00:33:20
just pronounces those cells and some
00:33:24
of you noticed that time that there is a way
00:33:26
to improve this move after all, just
00:33:27
copy and paste the command is a so-so
00:33:29
solution, but if we cough 4 5 or even
00:33:31
twenty times, the copy paste option is
00:33:33
no good,
00:33:34
what is the obvious solution to the problem, a loop, of course, we
00:33:36
use any loop, we
00:33:40
have a loop with the operator for voile and
00:33:42
so on,
00:33:43
we did it like this That's what we'll do in the first
00:33:45
version of the solution, I rewrote the program, a
00:33:47
depraved cough and one .
00:33:48
using a for loop,
00:33:50
however, now we have the
00:33:52
opportunity to rewrite the program
00:33:53
according to our today's lesson
00:33:55
mumrik in this way, let's say I
00:33:58
'll create a function called wallets,
00:34:00
try to imagine what it will
00:34:03
look like like if I need
00:34:05
someone to cough, I'll just use
00:34:07
printf inside With this function, I’ll do this essentially
00:34:10
every time you need to display an
00:34:12
inscription on the screen. The programmer would call
00:34:14
this a side effect. I’m not
00:34:16
passing values ​​to someone, but I’m performing
00:34:19
an action that can be implemented
00:34:20
visually, but this function, cough, does
00:34:23
it return values ​​judging by the
00:34:24
first one? there is no line type return
00:34:27
value type here, that is, it does
00:34:29
n’t give me anything in front of Rusnano, you can
00:34:30
produce some kind of visual effect,
00:34:31
but it won’t bring a sheet of paper like last
00:34:33
week, is it necessary and there is no input data,
00:34:35
therefore, here he will master it turns out
00:34:39
that with this option we seem to how
00:34:40
overdone
00:34:41
I made the program too complicated, went too far with
00:34:43
the number of lines of code, but it did not
00:34:45
become more functional, however, it could
00:34:47
serve as the basis for a more serious code with
00:34:49
more information, but what
00:34:52
about this option that I did,
00:34:54
just look at the code without a comment
00:34:56
at the beginning files file what drastic
00:34:59
changes I made introduced into each program
00:35:02
so a variable appeared out of the rows, and it’s
00:35:05
also better, really, let’s say
00:35:08
we’re expanding the functionality of the program or
00:35:10
the function, it still doesn’t
00:35:11
return anything to us modis side visual
00:35:14
effect, because we call the printer, but the
00:35:15
function appears, the parameter is determined by the
00:35:18
type of input data,
00:35:19
integer and name m impregnation, but it
00:35:22
could be anything, even times,
00:35:24
so that it would be completely clear to
00:35:26
me and we here too, the point is
00:35:29
how I made the function take input
00:35:31
data, and if you suddenly looked through our
00:35:34
manual on the course website before in the
00:35:35
fourth or fifth versions of this
00:35:37
program, you noticed that I went further
00:35:39
in generalizing the code of things
00:35:42
that both of them imitate sounds, they are
00:35:46
sound processes in themselves and so scratch you
00:35:48
would take a brick saif save and here I
00:35:51
did this, let's look at cough
00:35:54
or is this how to pronounce he and sneeze how to
00:35:57
say about honor like this so I generalized two
00:36:00
processes in the form of a single function by the name of
00:36:02
this one, which is interesting to us
00:36:04
today only because it also does not
00:36:06
return any data,
00:36:07
but how much input data does it have? 2 times
00:36:13
you want to use two arguments, then
00:36:15
just separate them with a comma and if then
00:36:17
you need to call function, then pay
00:36:19
attention, you simply call it with its first
00:36:21
argument in quotes, and as the
00:36:24
second argument, once again we just
00:36:26
have the building blocks for
00:36:28
the production and implementation of our own
00:36:29
functions, maybe you still have
00:36:32
questions about it and then let's go
00:36:35
back a level so to speak because
00:36:37
next week you will find a problem book on
00:36:40
cryptography, the art of encoding
00:36:41
information, in particular, you will be
00:36:43
working on encryption
00:36:44
and decryption of texts. In this regard,
00:36:47
on our agenda, the question
00:36:48
is also going on inside in the wilds of the text,
00:36:50
in addition to the ask symbols
00:36:52
from our introductory lesson and
00:36:54
how we can do this manage here is the
00:36:56
name of the emoticon in the form of text that can be entered
00:36:59
using the get function strings, for example,
00:37:01
from now on, get used to seeing
00:37:03
similar string data z and haze by
00:37:07
separate forces as if you were to give each cell that’s
00:37:10
how it is, in a
00:37:13
week or two you will represent each of these cells
00:37:15
separately a memory block,
00:37:17
therefore, that is, each of the letters is ultimately
00:37:20
represented by 8 dead ones,
00:37:21
and we will see what is happening in the bowels of
00:37:23
my computer, but for now it is enough to
00:37:26
look at it from this perspective at each
00:37:28
letter separately and what
00:37:30
makes us all happy is that here we can get to
00:37:32
each cell directly if suddenly you
00:37:35
need the first letter in the name of a language,
00:37:38
everything is as simple as shelling pears, and even with the
00:37:40
last letter just as easy, using
00:37:42
a new syntactic element, go
00:37:46
to the integrated development environment with
00:37:48
fifty, open the file string 0.7
00:37:51
and see here an example of breeds of completely
00:37:54
new pieces of software, to begin with, line number
00:37:57
nineteen I am familiar to us get string
00:38:00
common sense test can
00:38:02
someone explain in simple words
00:38:04
what is happening here you see it in
00:38:06
ordinary language as if for your neighbor
00:38:08
who does not go to the boobs in those days of
00:38:10
moral yeah the user must enter a
00:38:13
text that will be stored in the variable s
00:38:17
excellent receive a string from the user
00:38:19
and save it in variables with great
00:38:22
and so on the right we have a call to the function
00:38:23
geostring coverage up returns
00:38:25
the value that is assigned to the left
00:38:27
side, or rather to a variable by name with the
00:38:29
text designed for storage just
00:38:31
like that life and now line number 22 with a
00:38:34
comment in 21 obviously it prints
00:38:37
this text character by character per
00:38:39
line, but how to begin with we assigned the
00:38:41
value 0 to the variable and then how did we
00:38:43
get to the end of the name, smileys, floor, that
00:38:46
at the end of the name, I
00:38:48
can manually type the
00:38:49
last letter or its number, so
00:38:51
if we go back and z3 m white
00:38:57
so I can type in what are the
00:39:00
last letters and the name Larry
00:39:02
if it’s ours 0 we’re programmers zero
00:39:05
one two three four five that’s right say
00:39:08
so there are letters in the name 6 but if
00:39:10
you count from scratch then the last one turns out 5
00:39:12
pay attention to this attention, in the C language there is
00:39:16
a function named str or it just so happened
00:39:19
that programmers try to agree on
00:39:21
the names of functions that sound similar
00:39:23
to full-fledged words, so str len and
00:39:26
tostring lin string length
00:39:28
so what is the value of the string length for the
00:39:30
name of the smiley from this mvl 6 after all, such a
00:39:37
length is the name with milo 1 5 6 letters so and what does
00:39:41
this give to our loop we will go from 0 to
00:39:44
6 which will be five operations and what
00:39:46
will happen in this case is the
00:39:48
percentage sign the letter c the other day we found out that this is
00:39:51
a placeholder for what
00:39:52
for the symbol to for any character but 1
00:39:57
not for the whole line,
00:39:58
then a new line where the value will be displayed
00:40:00
and here is a new syntactic
00:40:02
construction
00:40:03
if you need to display the character of the
00:40:05
line with the serial number
00:40:07
oh then write the name of the line with open
00:40:10
square brackets oh close the
00:40:12
square brackets this is very convenient that
00:40:14
square brackets look like a box
00:40:16
in which the letter of the name is written, just like
00:40:19
in our picture, and now let’s
00:40:20
run the program on how it
00:40:24
works crazy qstring 0 dot slash string 0 and
00:40:29
now we need to write the very name of the program
00:40:31
does not ask for it because I didn’t use
00:40:34
the printer but that’s okay I know what
00:40:36
to do and now the name is displayed on the screen by pulling the
00:40:39
line and now let's
00:40:41
fool around, let's say
00:40:42
I don't know what the function is, but
00:40:44
assuming that the name cannot be
00:40:46
longer than 50 characters, let's
00:40:48
recompile the program and run it
00:40:49
again, but we will write the name of the smiley,
00:40:51
guess what will happen next
00:40:54
z3 m vai al will appear on the screen
00:40:56
almost 45 more bytes of information
00:41:02
again we have a question of memory
00:41:05
logic dictates that if we
00:41:07
really have this length as in the
00:41:09
picture
00:41:10
then we ask the program to continue to output print
00:41:14
print characters
00:41:15
until it reaches 50 but what
00:41:18
will happen in reality, let's check,
00:41:20
write the file name in a funny way, but the program succeeded, the
00:41:24
program produced a block of empty fields, here's
00:41:26
one of its funny symbols, similar to an
00:41:27
unusual one? however, the name of the smiley is written,
00:41:31
what about moving out in full, and what
00:41:33
if you display 500 extra elements on the screen, it’s
00:41:35
not torture to try to type,
00:41:38
restart the program to expand it to
00:41:41
full screen so that the smiley can be better seen,
00:41:44
and again we got it all, there are no
00:41:46
limits to self-indulgence, let’s risk it to the fullest
00:41:50
50 thousand characters this is no longer
00:41:55
funny at all so we qstring 0
00:41:57
there was no smiley
00:42:04
but great memory we are now
00:42:06
completely empty which is not so
00:42:08
bad at all what I’m trying to do actually
00:42:11
madness of the brave 500000 launch in full
00:42:17
screen let’s go get
00:42:18
milo here she has no idea
00:42:29
what this is such, but it doesn’t bode well for
00:42:30
those lucky ones who will have the opportunity to
00:42:33
work on summer
00:42:34
residents number one at the next consultation, you will still
00:42:37
encounter such a segmentation error,
00:42:39
in general, it is a very clear concept, it
00:42:41
concerns the problems of memory segments in the
00:42:43
user’s language, this means that we have
00:42:45
encroached on the
00:42:47
computer’s RAM where access is denied to us and
00:42:49
this is precisely the powerful power but also a
00:42:51
serious risk in the C language you have
00:42:54
free access to all memory to all
00:42:56
available byte operatives, to be
00:42:58
more precise, so even if your
00:43:01
smiley name has only six letters, but I can
00:43:03
deal with just the memory of as much as I wish
00:43:05
by the way, if you have ever come
00:43:08
across news that a server or
00:43:10
program has been hacked by hackers, this means
00:43:13
that someone has abused a
00:43:14
buffer overflow, we will talk about this in more detail
00:43:17
in a couple of weeks, there is no point in
00:43:19
tricking the computer into
00:43:21
switching the boundaries of his memory and at
00:43:23
that moment himself get something valuable from
00:43:26
this very memory, a password, for example,
00:43:28
a way to bypass the verification of Kelly's serial numbers,
00:43:30
the opportunity to force the computer and
00:43:32
execute the supporters, but let's
00:43:35
briefly return to reality where we
00:43:37
were working on a program with a function for
00:43:40
years and were faced with the unknown So far
00:43:42
nothing surprises among the first
00:43:44
three lines up to string .
00:43:46
and it turns out we have a
00:43:49
string library. speech or string library tea
00:43:51
header file string .
00:43:53
the river gives us permission for this function, page
00:43:56
whether if we remove this piece the computer will be indignant one way or
00:43:58
another, but you know that I will share
00:44:01
with you the subtleties line 22 here we have
00:44:04
somewhere hidden a weak point of an
00:44:06
unsuccessful structure, perhaps remember
00:44:09
how cycles are described on board, how
00:44:11
steps are repeated once over and over again the
00:44:14
initialization stage setting the condition for
00:44:15
executing the code then increasing the value
00:44:19
or some kind of change another condition code change
00:44:22
conditions code change and so on what is
00:44:27
the flaw here that worries
00:44:29
Khurnay yes the guy in blue the function call
00:44:33
happens many many times yes we
00:44:36
call ester flax many times however
00:44:38
what is the length of the smiley name during the
00:44:40
first execution of the code
00:44:42
6 and what is this length during the repeated
00:44:44
execution of the code still 6 because the
00:44:48
name of the smiley has not undergone any
00:44:49
changes in any of its parts, it
00:44:51
turns out that I essentially asked the
00:44:53
same question what is the length of the name smiley
00:44:56
what is the length of the smiley name what is the length of the
00:44:58
smiley name six times in a row
00:45:00
or seven it’s just stupid because the answer
00:45:02
doesn’t change the
00:45:03
solution is here in the string folder one
00:45:06
I have a slightly improved option and in
00:45:08
which folder string 2 I have the option they
00:45:11
will get the action just assigned a and
00:45:13
the value 0 but also separated by a comma declared a
00:45:15
second variable n in here there is
00:45:19
no need to repeat it anymore, moreover, it’s not even
00:45:21
worth it just n and it is assigned
00:45:23
the value of the function variable p years
00:45:27
now we have a function how many times
00:45:29
is executed 1 this is what it means to improve the
00:45:33
structure of the code as a whole as soon as the code
00:45:36
checked for errors, it
00:45:38
would be useful to look through it again, checking
00:45:41
whether the possible memory has been used to a minimum and the time for
00:45:44
processing the program, down to
00:45:45
milliseconds,
00:45:46
also pay attention, here
00:45:48
0 of
00:45:49
this version is written at the top, but we will return to it later,
00:45:52
but now let’s better go over the
00:45:54
acquired skills
00:45:56
in -first, we learned to work with
00:45:58
individual characters compared to the
00:46:00
introductory week, we are now
00:46:02
making full use of what seemed
00:46:03
incomprehensible and boring then, your capabilities
00:46:06
are expanding, and we haven’t gotten to
00:46:08
encryption yet, wait a week, it
00:46:10
turned out that some data types are
00:46:12
integer and fractional characters and strings,
00:46:14
some of them they can easily
00:46:16
turn into each other, for example,
00:46:18
when we talked about tables of
00:46:20
ask codes, here we have capital letters otpey yes
00:46:23
m bit we mentioned the connection between letters and
00:46:25
numbers, so this also works with
00:46:28
lowercase letters, the code for lowercase and
00:46:31
97 and for uppercase 65 flour for all
00:46:34
other letters in the same way there are
00:46:37
digital analogues in the table,
00:46:39
so let's quickly go through the
00:46:41
programs from the file ask 0 here are
00:46:44
mostly comments,
00:46:45
but you remember that
00:46:47
you can always study all the comments on our
00:46:49
website so what is happening here is the
00:46:51
main function fixed numbers are written here
00:46:53
since I know exactly what I need,
00:46:56
I know what I need, the result
00:46:57
is assigned the value 65 grams and then I count,
00:47:01
adding one at a time up to 26
00:47:03
letters and what will appear on the screen line by line
00:47:06
you can understand what is written in
00:47:09
this line what is the result Yes, and
00:47:11
maybe the letters will be displayed in
00:47:13
accordance with and together with their table
00:47:15
numbers, absolutely correctly, we will display the
00:47:18
letters and their digital correspondences on the screen
00:47:20
like this again, let’s remember that we have
00:47:23
a placeholder for a symbol, so that’s what it is,
00:47:25
this is a placeholder for an integer, then a
00:47:28
new line,
00:47:29
and here pay attention to the first
00:47:32
we substitute a and the value is not just oh but
00:47:34
with a clarification before that in parentheses
00:47:36
char that is a symbol that indicates to
00:47:39
the compiler that we need oh
00:47:41
not as the corresponding digit but as the
00:47:44
symbol itself but here is the second one
00:47:46
we insert a and the value should be Let’s
00:47:48
just compile made a ski with numbers 0
00:47:52
dot slash
00:47:53
mask and 0 and we have
00:47:56
the entire list with all the matches at hand, no
00:47:58
need to guess or calculate anything,
00:48:00
also a lowercase letter is displayed on the screen,
00:48:02
we have it written in the second half of
00:48:05
the program, the main thing is to understand that as soon as
00:48:08
you you catch the scheme and mechanics of
00:48:10
what is happening, it doesn’t cost you anything to
00:48:12
navigate the correspondences;
00:48:14
moreover, remember how you played code in school
00:48:16
or heard about such games from
00:48:19
friends, how to pass notes to each other
00:48:21
where it is written and a means b&b is
00:48:24
actually lost or what is more sophisticated
00:48:27
option how you deciphered it as a
00:48:29
child utter you just knew that a
00:48:30
is b
00:48:31
abe this is c but from a mathematical point of
00:48:34
view what happened was that a person
00:48:36
added a value to each letter, a
00:48:37
unit was added, that is, changing it b
00:48:40
in fact you changed 65 to 66 or simply
00:48:44
added one
00:48:45
this I used this mysterious technique with a
00:48:48
programming teacher, I
00:48:50
will have to do the same thing, adding
00:48:52
letters one by one, soon we will
00:48:54
use similar techniques for
00:48:56
real encryption and before encoding
00:48:58
information, we have also started working with
00:49:00
new libraries for today this is
00:49:02
string speech and here is a useful site for you,
00:49:04
I hope the reference with pectin
00:49:07
over collected for you by teachers will be useful if
00:49:09
you need to remember how page
00:49:11
lin functions, just enter the name of the function,
00:49:13
select from the list, it will appear quite
00:49:16
intelligibly and the description will appear, but if you suddenly
00:49:18
need a professional explanation
00:49:20
from linux, then click on the
00:49:22
carrot on the top right and there you have even the information but in
00:49:25
more complex terms, an extremely useful
00:49:27
guide to figure out who is
00:49:29
responsible for what next time we will deal with the
00:49:31
milk miracle words in with which the
00:49:33
whole world is chest-deep 3 photos but for now
00:49:36
Colton Ogden will stay with you and
00:49:38
we will see you on Wednesday translated
00:49:40
and voiced by studio vert diver commissioned by
00:49:44
java rush
00:49:57
what's going on here I'm a bunch of chocolate
00:50:02
for from and this is not usually how you do it but not
00:50:06
with your hands

Description:

Доп. материалы и задачи к лекции - https://javarush.com/quests/lectures?quest=QUEST_HARVARD_CS50&level=2 Весь курс CS50 - https://javarush.com/quests/QUEST_HARVARD_CS50 Каждый год примерно 3% студентов Гарвардского курса по основам программирования CS50 пытаются смошенничать во время учёбы, например, выдав чужой код за свой. Этой статистикой @David Malan поделился на пятой лекции CS50. Представляете, какой процент был бы в наших вузах?... Впрочем, не будем о грустном, давайте лучше о знаниях. Вот что вам расскажут в текущей лекции: - Баги. Без этих верных спутников разработчиков никуда не деться, нужно научиться их выискивать. Дэвид расскажет о некоторых типах багов. Начнет с тех, которые сложнее выцепить: логических; - Откровение: бесконечный цикл на самом деле не такой уж и бесконечный; - Функциональная декомпозиция: прием для повышения читаемости кода и удобства кодирования; - Знай свои фигурные скобки: область действия переменных; - Объявление функций до реализации: специально для C; - Строки и как с ними работать; - Что такое ошибка сегментации; - Милые щеночки! В стриме. Не пропустите=). - Как едят шоколадки и M&M’s в Гарварде. Наглядное пособие. … ну а следующая лекция будет еще интереснее: молочное чудо Ovaltine и криптография. Одно только звучание завораживает!

Preparing download options

popular icon
Popular
hd icon
HD video
audio icon
Only sound
total icon
All
* — If the video is playing in a new tab, go to it, then right-click on the video and select "Save video as..."
** — Link intended for online playback in specialized players

Questions about downloading video

mobile menu iconHow can I download "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]" video?mobile menu icon

  • http://unidownloader.com/ website is the best way to download a video or a separate audio track if you want to do without installing programs and extensions.

  • The UDL Helper extension is a convenient button that is seamlessly integrated into YouTube, Instagram and OK.ru sites for fast content download.

  • UDL Client program (for Windows) is the most powerful solution that supports more than 900 websites, social networks and video hosting sites, as well as any video quality that is available in the source.

  • UDL Lite is a really convenient way to access a website from your mobile device. With its help, you can easily download videos directly to your smartphone.

mobile menu iconWhich format of "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]" video should I choose?mobile menu icon

  • The best quality formats are FullHD (1080p), 2K (1440p), 4K (2160p) and 8K (4320p). The higher the resolution of your screen, the higher the video quality should be. However, there are other factors to consider: download speed, amount of free space, and device performance during playback.

mobile menu iconWhy does my computer freeze when loading a "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]" video?mobile menu icon

  • The browser/computer should not freeze completely! If this happens, please report it with a link to the video. Sometimes videos cannot be downloaded directly in a suitable format, so we have added the ability to convert the file to the desired format. In some cases, this process may actively use computer resources.

mobile menu iconHow can I download "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]" video to my phone?mobile menu icon

  • You can download a video to your smartphone using the website or the PWA application UDL Lite. It is also possible to send a download link via QR code using the UDL Helper extension.

mobile menu iconHow can I download an audio track (music) to MP3 "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]"?mobile menu icon

  • The most convenient way is to use the UDL Client program, which supports converting video to MP3 format. In some cases, MP3 can also be downloaded through the UDL Helper extension.

mobile menu iconHow can I save a frame from a video "5. CS50 на русском: Лекция #5 [Гарвард, Основы программирования, осень 2015 год]"?mobile menu icon

  • This feature is available in the UDL Helper extension. Make sure that "Show the video snapshot button" is checked in the settings. A camera icon should appear in the lower right corner of the player to the left of the "Settings" icon. When you click on it, the current frame from the video will be saved to your computer in JPEG format.

mobile menu iconWhat's the price of all this stuff?mobile menu icon

  • It costs nothing. Our services are absolutely free for all users. There are no PRO subscriptions, no restrictions on the number or maximum length of downloaded videos.