Print rectangle pattern. See example for more details.
Input Format
First and only line of input contains a single integer N – the size of the rectangle.
Constraints
1 <= N <= 50
Output Format
For the given integer, print rectangle pattern as shown in example.
Inputcopy | Outputcopy |
---|---|
5 | 5432* 543*1 54*21 5*321 *4321 |
Explanation 0
Self Explanatory
Solutions:
import java.util.Scanner;
public class RectanglePattern {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
for (int i = 1; i <= N; i++) {
for (int j = N; j >= 1; j--) {
if (j == i) {
System.out.print("*");
} else {
System.out.print(j);
}
}
System.out.println();
}
scanner.close();
}
}