-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInverted_Triangle_Number_Asterik_Pattern.java
More file actions
44 lines (39 loc) · 1.07 KB
/
Inverted_Triangle_Number_Asterik_Pattern.java
File metadata and controls
44 lines (39 loc) · 1.07 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
import java.util.*;
public class InvertedTriangleNumberAsterik {
public static void main(String[] args) {
System.out.print(Enter a Number: );
int n = new Scanner(System.in).nextInt();
int ct, beg=1, val, f=0, dCt=0;
while(n>0){
ct=2*n-1;
System.out.print("-".repeat(dCt++));
if(f==0){
f=1;
val=beg;
while(ct>0){
System.out.print(val++);
ct--;
if(ct>0){
System.out.print("*");
ct--;
}
}
}
else{
f=0;
beg++;
val=beg;
while(ct>0){
System.out.print("*");
ct--;
if(ct>0){
System.out.print(val++);
ct--;
}
}
}
System.out.println();
n--;
}
}
}