-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPattern27.java
More file actions
49 lines (36 loc) · 1.08 KB
/
Pattern27.java
File metadata and controls
49 lines (36 loc) · 1.08 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package com.company;
import java.util.Scanner;
public class Pattern27 {
public static void main(String[] args) {
System.out.print("Enter the number of rows with while:");
Scanner sc = new Scanner(System.in);
int rows = sc.nextInt();
int nsp=rows-1;
int nst=1;
int row=0;
while(row<rows) {
int csp=0;
while (csp < nsp) {
System.out.print(" "+"\t");
csp++;
}
int cst=0;
int val=1;
while (cst < nst) {
System.out.print(val + "\t");
// preperation for every column
cst++;
if (cst <= nst / 2) {
val++;
}
else {
val--;
}
}
System.out.println();
nst=nst+2;
nsp--;
row++;
}
}
}