-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatternQuestion21.java
More file actions
33 lines (28 loc) · 872 Bytes
/
patternQuestion21.java
File metadata and controls
33 lines (28 loc) · 872 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
30
31
32
33
package PatternPrintingAll;
import java.util.Scanner;
public class patternQuestion21 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter n: ");
int n = scanner.nextInt();
int nsp = 1;
int nst = n;
for (int i = 0; i < n; i++) {
for (int j = 0; j <=nsp; j++) {
System.out.print(" ");
}
for (int j = 0; j <nst ; j++) {
if(i==0 && j==1){
System.out.print(" ");
}
else if(i+j==n-2){
System.out.print(" ");
}
else
System.out.print("1 ");
}
nsp++;
nst-=2;
System.out.println();
}
}}