-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2_4.java
More file actions
29 lines (23 loc) · 762 Bytes
/
Lab2_4.java
File metadata and controls
29 lines (23 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class Lab2_4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the rows :");
int rows = input.nextInt();
if (rows < 1 || rows > 15) {
System.out.println("Error");
}
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= (rows - i) * 2; j++) {
System.out.print(" ");
}
for (int k = i; k >= 1; k--) {
System.out.print(" " + k);
}
for (int l = 2; l <= i; l++) {
System.out.print(" " + l);
}
System.out.println("");
}
}
}