We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Printing Pattern Using Loops
Printing Pattern Using Loops
Sort by
recency
|
1001 Discussions
|
Please Login in order to post a comment
Solution 2 int main() {
}
int main() {
}
This is an easy solution based on make square legth ( 2*n-1 ) measuring the distance to the middle whose value is known =1 when i=j=n small example for n=3 so it willl be square of 3*2-1=5
Here is the logic that I used:
{n, n-1, n-2, ..., 1, ..., n-2, n-1, n}
.Those counters can be built by looping from
(n-1)
to(1-n)
, then for each value calculatingabs(value) + 1
.