Hey, guys, what's up?
So today we are going to solve one more interesting pattern printing problem.
So read and read in and we have to print below batton.
So what is the burden so for any cause five.
My pattern is.
One, two, three, two.
Three, four, five, four, three.
Four, five, six, seven, six, five, four, five, six, seven, eight, nine, eight, seven,
six, five.
So if you remember, we have already sold this question and SolarWorld right now, if we will write
the actual C++ code for solving this problem.
So if you're looking at a league of the value of and there's five, I am renting five rows.
OK, so I need a loop and this loop will run and times.
OK, so how many species I have to print, I have to print.
And minus eight species.
OK, so I have to print and minus ice pieces.
So for a year through, I have to print and minus a.
Spaces then.
Now, if you look at it fully, first, I am printing increasing numbers.
So the numbers are increasing.
So how many numbers, how many increasing numbers I have to print?
So if the value of AI is five.
I am printing five increasing numbers.
So I have to print.
I see increasing numbers from where to start starting from.
Starting from I.
So if you look carefully at the value of Phase five to the first number is five, if the value of AI
is for the first number is.
For now after this.
I have to print decreasing numbers.
So how many decreasing numbers I have to print.
So if the value of I is four, I am printing three decreasing numbers.
If the value of I use five, I am printing for decreasing numbers.
So I have to print I minus one.
Decreasing numbers.
Now, from where to start, so the value of ICE five, I am starting from eight, which is the way minus
two.
Similarly, the value of AI is four.
I am starting from six, which is the way minus two.
So I am minus one.
The closing numbers starting from the way minus two.
Now w we have printed the entire row.
When I printed the end bad I year through I have to go to next to lose.
So I will print C out and lane.
So in total how many loops do I need here.
So I need one outer loop, one loop, four spaces, one loop for printing increasing numbers and when
loop for printing decreasing numbers.
OK.
So in total I will need four loops out of which one loop is outer loop and the other three loops are
in a loop.
OK.
So I think their logic and the problem is clear.
So let say I called.
So let us name this violence.
No pattern to sue.
Badon do not see BP.
So first so first let us dig in, Burt Fundi User.
So inten seen and seen.
And now we have decided that.
So first, I have to run a loop and times so fun.
So for running a loop and times and time equals one while I is less than or equal to N and here I.
Plus plus.
So with the help of.
These tea I when I left English to end and I plus plus this loop is going to run and times.
Now each time this loop is running, I will print.
I through.
So for printing the ideal first I have to print and minus I space's ok.
And minus ice pieces.
So and Spees equals one vile space is less than or equal to two and minus eight pieces.
So N minus I space's.
Space plus space plus, plus.
Now this loop will run and minus eight times, and each time this loop is running.
What I will do, I will print a space.
OK, so after printing spaces, what I have to do, I have to print I increasing numbers starting from
I I increasing numbers starting from my.
That means I need.
So that means I need a loop and this loop will run eight times.
Also, I need a value visual initially B I.
Because you can see here, if the value of eyes for the first number that I have to print is four.
So initially value equals I.
And you can see here four.
Then five, then six and then seven.
So each time I am printing the value I will increase the value by one.
So I at times I loop.
Each time I will print so out value.
Initially the values.
I add value plus.
Plus.
So eight times.
OK, so let's stick.
So end value equals I.
Because we have to start printing from.
I know how many increasing numbers I.
Increasing numbers.
So end count equals one.
While ground is less than or equal to how many.
Using numbers I increasing numbers count plus plus.
So each time this loop is running what I will do I will see out value.
Now after printing that value, I have to increase the value by one.
OK.
So this loop is for printing the numbers in increasing orders.
You can see here.
So I have to run the loop eight times.
So what I did, I take a variable count, which is initially one that I check counted less than I close
to I.
And then I did count plus plus.
And each time this loop is running, I am printing value.
And then I am increasing the value by when.
So then then now I have to print a minus one, the closing numbers, I'm minus one, negative numbers.
So for running.
So I need a loop and this loop will run.
How many number of times I minus one names.
So I loop for running.
So we need a loop that will run a minus one times.
So what is the starting value.
So starting value is the way minus two.
Four, five.
The starting.
We lose it.
Which is way minus two.
Its value is initially the way minus two.
Okay.
And each time I am printing the value the value is decreased.
Eight, seven, six and five.
So what I will do.
Value minus minus because the values are decreasing.
So I am minus one times and the first we lose at the way minus two.
So the first value.
So the first value is to a minus two.
And how many times I have to run the loop?
A minus one times.
So consequence one way count is less than or close to a minus one times.
We have two in the loop so count plus plus.
Now, each time this loop is learning, I have to see out value since the numbers are printed in the
closing order.
So value will be diclemente by one.
So value minus minus.
Now we have printed the spaces.
We have been today increasing numbers.
We have been decreasing the most.
Now it is the right time to go to next line.
So see out and line.
So this is the complete.
Called.
OK, so this loop is for printing spaces.
This loop is for printing increasing numbers and this loop is for printing decreasing numbers.
OK, so let me write here.
For spaces.
Now, this is forward, increasing numbers.
And this loop is for the closing numbers.
OK.
So let us test our program, how it is working.
Let's say the value of this five, some output is correct, one down to three.
In closing order, three, four, five, including order four, five, six, seven, inclosing order
five, six, seven, eight, nine, including order and then decreasing orders.
OK.
Lettuce tested for more will lose.
Let's say an enclosed tree.
OK.
So our court is a hundred percent correct.
OK.
So that is it for this video.
Thank you.