forked from 14visheshjain/DataStructure-Algorithm-in-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPattern3.java
More file actions
50 lines (45 loc) · 707 Bytes
/
Pattern3.java
File metadata and controls
50 lines (45 loc) · 707 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
39
40
41
42
43
44
45
46
47
48
49
50
// Author: Vishesh Jain
//Pattern:-
//5
// *
// ***
// *****
// *******
//*********
// *******
// *****
// ***
// *
package first;
import java.util.Scanner;
public class Pattern3 {
public static void main(String[] args) {
Scanner a = new Scanner(System.in);
int n = a.nextInt();
int i=1,j=1;
while(i<=n) {
j=1;
while(j<=n-i) {
System.out.print(" ");
j++;}
j=1;
while(j<= 2*i-1) {
System.out.print("*");
j++;}
System.out.println("");
i++;}
i=n-1;
j=1;
while(i>0) {
j=1;
while(j<=n-i) {
System.out.print(" ");
j++;}
j=1;
while(j<= 2*i-1) {
System.out.print("*");
j++;}
System.out.println("");
i--;}
}
}