Computer Science, asked by arunjagatha, 8 months ago

woung Type Question
Decode the logic and print the pattern that corresponds to the given input.
Input format
Single Integer N
Output format
Output is the form of pattern
Code constraints
2<=N<=100
Sample testcases
Input 1
Output 1
10203010011012
*** 4050809
*****607
Input 2
Output 2
C156HC
1020304017018019020
**50607014015016
****809012013
****** 10011
Note :​

Answers

Answered by Anonymous
0

Answer:

Input : n = 4

Output :

1

3*2

4*5*6

10*9*8*7

Input : n = 5

Output :

1

3*2

4*5*6

10*9*8*7

11*12*13*14*15

Explanation:

printPattern(int n)

Declare j, k

Initialize k = 0

for i = 1 to n

if i%2 != 0

for j = k+1, j < k+i, j++

print j and "*"

print j and new line

k = ++j

else

k = k+i-1

for j = k, j > k-i+1, j--

print j and "*";

print j and new line

Similar questions