3 Replies - 192 Views - Last Post: 04 November 2017 - 09:36 AM Rate Topic: -----

#1 asgorde  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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?

Posted Image

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  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13485
  • View blog
  • Posts: 53,841
  • Joined: 12-June 08

Re: How to make the X pattern?

Posted 04 November 2017 - 09:16 AM

What have you tried?
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 5073
  • View blog
  • Posts: 13,697
  • 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

Was This Post Helpful? 0
  • +
  • -

#4 asgorde  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1