12916 - Reversed Number Pyramid Pattern   

Description

Now let the user input an integer n, followed by a “pattern”, represented by another integer.
If  n==5 and if the pattern == 1, then your program should output:

55555
4444
333
22
1

If  n == 6 and if the pattern == 2, then your program should output:

654321
54321
4321
321
21
1

If the user inputs any pattern other than 1 or 2, then your program should output the following:

Unrecognized pattern!

 

 

Dont' forget \n !

Input

N, P, such that N belogs to the set of positive integers, and P belongs to set {1, 2}.

Output

N, N-1, N-2, ..., 1

N-1, N-2, ..., 1

N-2, N-3, ..., 1

....

1

or

N, N, N, ..., N

N, N, ..., N

N, N

N

or

Unrecognized pattern!

Sample Input  Download

Sample Output  Download

Tags




Discuss