-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPattern6.java
More file actions
38 lines (37 loc) · 930 Bytes
/
Pattern6.java
File metadata and controls
38 lines (37 loc) · 930 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
34
35
36
37
38
import java.util.Scanner;
public class Pattern6 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("enter row");
int n=s.nextInt();
int row=1;
int k=n;
while (row<=2*n-1){
int space=0;
int col1;
int col2;
col1=k;
space=2*(n-col1)-1;
if (space<0)
space=0;
col2=2*n-1-col1-space;
while (col1>0){
System.out.print("*");
col1--;
}
while (space>0){
System.out.print(" ");
space--;
}
while (col2>0){
System.out.print("*");
col2--;
}
if (row<n)
k--;
else k++;
System.out.println();
row++;
}
}
}