Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
So welcome back to the solutions of the EGS shape exercise.
And in this video, what we are going to do is simply to talk and explain how this shape can be printed
by using our C programming language.
So I hope you're excited, at least at least a little bit, OK, because this exercise is actually very
interesting in the concept.
And the approach here is not so trivial because a lot of students at the beginning of their career are
requested to make this exercise, or at least very similar exercises.
And they are kind of getting stuck on this one.
So let's talk about how we in me and you should approach these kind of exercises.
And basically, I would like to know if any of you guys succeeded to bring this on your first attempt
when your second attempt or maybe you got, for example, stuck and you are looking at this video to
understand how it should be done.
So without further ado, let's start working.
And the first question is basically, how should we treat to this exercise how we should even start
using it?
So one of the options here is simply to understand that we cannot print this whole thing just by using
one print offline and without specifying some condition, not conditions, but some logic behind it.
Right.
We can simply say something like this.
Print F, big X, right.
It's not going to work.
It's not going to bring this like this pattern.
But what we have to do is, first of all, try to break what we see here to a couple of rows in a couple
of columns.
So first of all, what I can see here is once again, that's a pattern, right?
Just like we've seen probably in previous exercises, it simply prints asterisks.
And here we have some blank space.
And what you have to understand is that this blank space is not actually so blank, these space blank
space, it consists of simply using space characters.
OK, so it's not empty.
It's not some void area.
It simply consists of printing the space and then printing another space in another space.
So here we have five spaces printed to the screen.
Here we have three spaces, one space, and that's it.
So that's the first know that you have to understand about this exercise is probably we are going to
use your spaces in some constructions with these spaces in order to print all of these shape.
And the second thing that you have to understand here is that we are simply going to take like to take
into consideration the rows and the columns.
So we are going to print first of all, our first attempt is going to be to print these little nice,
nice small leaks that consists of three rows and three columns.
Right.
So that's the first shape that I want us to try print to the screen.
This one.
So the approach is very simple, what we should do simply is printing OK, and in this first print of
command we are going to print the first line in the first line consists of Starbright space and a star.
Right.
We can see Star Space Star, then we have a backslash and simply to go on line to the next line.
So then we have another print F and what these print F consists of, it consists of just one star.
And also the last line consists of pretty much the same.
Right.
That's this this line and this line.
They are both identical, kind of identical.
So there you go.
You have your figure.
So let's try to build and run it and see if it works exactly as we expected.
OK, so that's that's what happens, guys, because we have a star in space and a star, so a star space
and a star.
And here we have just one star.
Right.
But what's the problem?
The problem is that if we look at this shape, we can see that if we are looking at it in kind of a
rectangle format, then before these little nice asterisk, we have a space.
Right.
So that's something we didn't take into account.
And that's why it was not printed in the middle, as we would have expected.
So let's simply just add a space here before and maybe also a space after.
And there you go.
You can see also right here in the print of comments that the shape is starting to get kind of similar
shape to what we wanted.
So let's build and run it and we can see that that's exactly the small shape that we wanted to print.
Awesome.
So that's kind of works.
And now what we have to do is simply to expand it a little bit further.
So let's take it right here and also take this one right here.
So I'm doing this because that's how I requested you to approach this exercise.
And first of all, to print a small rectangle, a small X and then some larger X and then the large
one that we wanted initially.
So what we have to do now is simply to print this additional line before.
Right.
So it's going to be printed out.
And here we have star and one to three spaces.
So star one, two, three star and resolution.
And that's the same line that we added to the end of the sixth shape.
So print f star.
OK, so there you go.
And what you can notice here is that if you take a look at this shape, you can see that it's not similar
to these six.
Right.
And if you build and run it, you will also see that you get some sort of strange Kelaher.
Right.
But not an X.
So what do we have to do is simply to understand that previously we didn't use in this line any space
before.
But since we've expanded this exercise, we have now to use a space before this line.
So that's going to be one space and that's going to be one space.
And also before the middle the middle asterisk, what do we have to do is to add additional space.
So now it's trying to kind of look looks like we want it to.
Right.
So build and run it.
And there you go.
You've created your X.
So what we've done once again was simply we simply noticed that previously the shape that we've printed,
the small shape, are in the first and last lines.
And it all you didn't have any spaces before, but now since we expanded it.
Right.
So if we look at this rectangle shape, we know that here should be something right here should be some
space.
So that's why we added a space here in a space here.
And also we noticed that now in order to keep this star in the middle, we need to add beforehand two
spaces.
OK, so if we don't specify exactly afterwords, also two spaces in one space here in one space here,
it really doesn't matter because.
Well, anyway, we simply just get one line, one line ahead by using these backslash M.
So I hope that's clear so far.
And finally, let's add of the last line, which is this one.
So one and two.
Right.
That's how we do it.
And just expand, expand, expanded a little bit further.
And so printf in here we have asterisk and asterisk and one, two, three, four, five, five spaces.
One, two, three, four, five.
Risk explosion and also add this line to the end.
And one thing that we have to remember for these kind of things is simply to move once base all of these
characters that were previously so one one, one, one and one.
And basically there you go.
You got your X shape printed to the screen.
And you also understand the main logic behind it, how to approach it, how to tackle this problem.
Basically, most of the things you need to print, most of the shapes that you want.
So if you want to print any other letters, so give it a shot to give it a try.
I think that there should be no problems, no actual problems, at least for you.
Once you understand the concept of using rows and columns and understanding the spaces and to start
with some smaller figure, for example.
And yeah.
So I hope you like this video and I'll see you in the next one.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.