# How to make the X pattern?

Page 1 of 1

## 3 Replies - 225 Views - Last Post: 04 November 2017 - 09:36 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=407385&amp;s=7d21dbc3c8e5afff1cf49c67c73727a8&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 asgorde

Reputation: 0
• Posts: 5
• Joined: 04-November 17

# How to make the X pattern?

Posted 04 November 2017 - 08:57 AM

Input
The​ ​input​ ​consists​ ​of​ ​1​ ​integer​ ​N​ ​ ​ ​that​ ​represents​ ​the​ ​size​ ​of​ ​the​ ​box. 1 ≤ N ≤ 100)(

Output
Output​ ​the​ ​box​ ​with​ ​size​ ​of​ ​N.
1st​ ​Sample​ ​Input 6

Output​ ​for​ ​1st​ ​Sample​ ​Input
******
**​ ​​ ​**
*​ ​**​ ​*
*​ ​**​ ​*
**​ ​​ ​**
******

2nd​ ​Sample​ ​Input 7

Output​ ​for​ ​2nd​ ​Sample​ ​
*******
**​ ​​ ​​ ​**
*​ ​*​ ​*​ ​*
*​ ​​ ​*​ ​​ ​*
*​ ​*​ ​*​ ​*
**​ ​​ ​​ ​**
*******

3rd​ ​Sample​ ​Input 1

Output​ ​for​ ​3rd​ ​Sample​ ​Input
*

Note:​​ ​Always​ ​print​ ​a​ ​newline​ ​(\n)​ ​at​ ​the​ ​end​ ​of​ ​the​ ​answer.

----------------------------------------------------------------------------
Can anybody help me on how to make the X pattern?

it's a little bit messy on the post, here is the screenshot of the output

Is This A Good Question/Topic? 0

## Replies To: How to make the X pattern?

### #2 modi123_1

• Suitor #2

Reputation: 13952
• Posts: 55,691
• Joined: 12-June 08

## Re: How to make the X pattern?

Posted 04 November 2017 - 09:16 AM

What have you tried?

### #3 Martyr2

• Programming Theoretician

Reputation: 5186
• Posts: 13,914
• Joined: 18-April 07

## Re: How to make the X pattern?

Posted 04 November 2017 - 09:20 AM

Doing patterns like this is always about looping. You are typically going to have a loop that goes the size of N and another that has rows R. Within that you have some decisions on when to print the asterisk and when not. Each iteration typically changes the if statement execution.

To help get you started thinking about this you can check out my blog article on shape building with loops...

http://www.coderslex...pes-with-loops/

It is in Java but really simple enough to get the idea no matter what the language is. I always advise people to study the pattern and how each row is different than the one before it because that will describe how the inner if/else/loops are going to change as it iterates.

This post has been edited by Martyr2: 04 November 2017 - 09:20 AM

### #4 asgorde

Reputation: 0
• Posts: 5
• Joined: 04-November 17

## Re: How to make the X pattern?

Posted 04 November 2017 - 09:36 AM

I've already got it, never mind