dimanche 31 octobre 2021

Pattern forming java..Not able to come up with a method

THE QUESTION IS:

Analyse the given pattern and print for the given interger N.

Input Format

A single digit N will be given.

Constraints

1<=N<=100

Output Format

It should print the pattern

Note: Even digit is a special condition, identify it accordingly to proceed the algo.

Sample Input 0

9

Sample Output 0

 * * 1 * *
 * *222* *
 * 3 3 3 *
 *4* 4 *4*
 555555555
 *4* 4 *4*
 * 3 3 3 *
 * *222* *
 * * 1 * *

Explanation 0

When the input is given as 9, It prints the following pattern. Analyse the pattern and come up with an algorithm to satisfy any given number.

The numbers have been printed straight and diagonally ..but not able think of a method to implement this...

Aucun commentaire:

Enregistrer un commentaire