Write a java program to display the following patterns.
Input:
7
Output:
7 6 5 4 3 2 1
7 6 5 4 3 2
7 6 5 4 3
7 6 5 4
7 6 5
7 6
7
import java.io.*; import java.util.*; public class temp{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter any number: "); int rows = sc.nextInt(); System.out.println(); for (int i = 1; i <= rows; i++) { for (int j = rows; j >= i; j--) { System.out.print(j+" "); } System.out.println(); } } }
INPUT_1:
Enter any number: 5
OUTPUT:
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
INPUT_2:
Enter any number: 7
OUTPUT:
7 6 5 4 3 2 1
7 6 5 4 3 2
7 6 5 4 3
7 6 5 4
7 6 5
7 6
7
INPUT_3:
Enter any number: 3
OUTPUT:
3 2 1
3 2
3
INPUT_4:
Enter any number: 10
OUTPUT:
10 9 8 7 6 5 4 3 2 1
10 9 8 7 6 5 4 3 2
10 9 8 7 6 5 4 3
10 9 8 7 6 5 4
10 9 8 7 6 5
10 9 8 7 6
10 9 8 7
10 9 8
10 9
10
INPUT_5:
Enter any number: 12
OUTPUT:
12 11 10 9 8 7 6 5 4 3 2 1
12 11 10 9 8 7 6 5 4 3 2
12 11 10 9 8 7 6 5 4 3
12 11 10 9 8 7 6 5 4
12 11 10 9 8 7 6 5
12 11 10 9 8 7 6
12 11 10 9 8 7
12 11 10 9 8
12 11 10 9
12 11 10
12 11
12
INPUT_6:
Enter any number: 2
OUTPUT:
2 1
2
INPUT_7:
Enter any number: 6
OUTPUT:
6 5 4 3 2 1
6 5 4 3 2
6 5 4 3
6 5 4
6 5
6
ILLUSTRATION
![](http://www.fcukthecode.com/wp-content/uploads/2022/04/2.png)