Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,090 --> 00:00:00,900
Welcome back.
2
00:00:01,170 --> 00:00:07,560
And in this video, we are going to solve the challenge of printing out in isosceles triangle using
3
00:00:07,590 --> 00:00:08,490
asterisks.
4
00:00:08,760 --> 00:00:14,520
So an asterisk is just like a character that you can print on your screen, just like you printed out
5
00:00:14,520 --> 00:00:17,400
the letter or characters of Hello World Message.
6
00:00:17,460 --> 00:00:19,740
So similarly can be done here.
7
00:00:19,930 --> 00:00:25,320
So to solve that in the first way, we can just use three print of commands, right.
8
00:00:25,470 --> 00:00:32,610
So on the first line to print one asterisk, we will use printer and print out one asterisk.
9
00:00:32,940 --> 00:00:34,950
And also add a backslash.
10
00:00:34,950 --> 00:00:38,970
And at the end, on the second line, we will print three of them.
11
00:00:39,610 --> 00:00:40,080
Right.
12
00:00:40,390 --> 00:00:41,280
One, two, three.
13
00:00:41,400 --> 00:00:45,270
Add a backslash and add the same for the third line.
14
00:00:45,480 --> 00:00:45,730
Right.
15
00:00:45,750 --> 00:00:48,040
We're using multiple print F commands.
16
00:00:48,060 --> 00:00:50,100
So one, two, three, four, five.
17
00:00:50,520 --> 00:00:51,750
And the backslash.
18
00:00:51,850 --> 00:00:53,130
And there you go.
19
00:00:53,340 --> 00:00:59,100
So now if we are to build and run this program, we will see these triangular right here.
20
00:00:59,280 --> 00:01:02,210
And we can see that it's not exactly what we wanted.
21
00:01:02,210 --> 00:01:02,590
Right.
22
00:01:02,850 --> 00:01:04,620
Although that's a triangle.
23
00:01:04,650 --> 00:01:06,570
We should reorder there with a little bit.
24
00:01:06,720 --> 00:01:13,260
And that's why the main thing in this exercise is to notice how how we can use correctly these lines,
25
00:01:13,260 --> 00:01:19,640
spacing between these asterisks and how we can use the backslash and the new lines here correctly.
26
00:01:19,860 --> 00:01:22,320
So, first of all, to place the asterisk.
27
00:01:22,700 --> 00:01:30,450
And the first line at the center of the triangle, we will just add two line spaces here and before
28
00:01:30,450 --> 00:01:33,190
the asterisk and two lines business afterwards.
29
00:01:33,600 --> 00:01:37,860
So there will be a total of five characters just like we have at the base.
30
00:01:38,100 --> 00:01:42,410
Then we would like to move the three asterisks here.
31
00:01:42,510 --> 00:01:42,790
OK.
32
00:01:42,860 --> 00:01:50,160
And the second line to the Medo and we can do that by just adding one line space before and one line
33
00:01:50,160 --> 00:01:51,210
space after.
34
00:01:52,050 --> 00:01:58,890
And you can see that right now it starts to make some form the actual form that we wanted it to be.
35
00:01:59,130 --> 00:02:06,920
So on the third line will live it as sees no line spaces, no line spaces actually are needed here.
36
00:02:07,320 --> 00:02:11,220
We already got our five characters at the base, as it should be.
37
00:02:11,430 --> 00:02:12,790
And now let's run it.
38
00:02:12,810 --> 00:02:14,730
Guys, let's build and run.
39
00:02:14,970 --> 00:02:15,960
And there you go.
40
00:02:16,050 --> 00:02:21,690
And isosceles triangle of asterisk, exactly as requested.
41
00:02:21,870 --> 00:02:22,590
Good job.
42
00:02:22,800 --> 00:02:29,610
So the biggest trick here in these exercises to properly use these lines, bases and the new line as
43
00:02:29,610 --> 00:02:30,570
we explain here.
44
00:02:30,810 --> 00:02:36,560
And now, once you've got some experience with that, let's try printing goal of this, try and going
45
00:02:36,570 --> 00:02:37,800
just one print off-line.
46
00:02:38,220 --> 00:02:40,680
So, first of all, let's clean all of this.
47
00:02:41,130 --> 00:02:41,580
Right.
48
00:02:41,880 --> 00:02:45,390
And now we will start just like with the previous example in 3-D.
49
00:02:45,510 --> 00:02:50,980
The first line using these two spaces before and after these Suan asterisks.
50
00:02:51,000 --> 00:02:58,530
So print here, add two spaces, add one asterisk and add two other spaces.
51
00:02:58,770 --> 00:03:05,600
Now that center, then let's add the backslash and to go to the next line.
52
00:03:05,850 --> 00:03:13,080
Then instead of using another print of command, we'll just add the second line because we will already
53
00:03:13,080 --> 00:03:14,280
be on the second line.
54
00:03:14,310 --> 00:03:15,810
Thanks to these Becs Lashan.
55
00:03:15,810 --> 00:03:16,140
Right.
56
00:03:16,770 --> 00:03:21,180
And here we'll use just one space line and then the three asterisks.
57
00:03:21,210 --> 00:03:28,470
So once baseline three asterisk, another space line and a backslash and at the end to go one line down.
58
00:03:28,650 --> 00:03:35,370
Now we can print five of them at the base at the last line and add the last backslash Lashan.
59
00:03:35,430 --> 00:03:37,560
And of course, a semicolon at the end.
60
00:03:37,890 --> 00:03:42,120
And one thing I forgot to do is to return zero.
61
00:03:42,720 --> 00:03:44,580
And hopefully we did everything right.
62
00:03:44,610 --> 00:03:48,190
Let's try to build and run it and very go.
63
00:03:48,450 --> 00:03:49,740
It works like charm.
64
00:03:49,770 --> 00:03:56,310
Basically, it's just the same as we've seen previously when we use their three printf lines.
65
00:03:56,340 --> 00:04:03,100
OK, the three printf commands jazz that right now we've used it in one print command.
66
00:04:03,300 --> 00:04:07,440
So that's a good practice for these radio guys and for these exercises.
67
00:04:07,890 --> 00:04:11,130
And one less thing for this video.
68
00:04:11,220 --> 00:04:17,730
Before we finish this exercise, I would like to ask you a question to think about and try to solve
69
00:04:17,730 --> 00:04:18,480
it on your own.
70
00:04:18,720 --> 00:04:24,240
We've used the different number of line spaces before this sequence of fast rescreen every line.
71
00:04:24,750 --> 00:04:31,020
And also, we've used the same number of spaces of line spaces right after the sequence at every line.
72
00:04:31,200 --> 00:04:31,590
All right.
73
00:04:31,620 --> 00:04:33,020
So we can see it right here.
74
00:04:33,020 --> 00:04:37,800
And there are spaces are right after the asterisk as well as here.
75
00:04:37,980 --> 00:04:40,320
So the question is, do we actually need it?
76
00:04:40,740 --> 00:04:44,910
Do we need these spaces right after we've written a sequence of asterisks?
77
00:04:45,420 --> 00:04:48,510
Or maybe we can simply put a backslash in right after.
78
00:04:48,870 --> 00:04:51,120
And we'll be good.
7071
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.