-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGalaxyOfStars.java
58 lines (48 loc) · 1.2 KB
/
GalaxyOfStars.java
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
51
52
53
54
55
56
57
58
import java.util.*;
class Solution {
public static void print(int n) {
int i,j;
if(n%2==0)
n=n+1;
for(i=0;i<=(n/2)+1;i++){
for(j=0;j<i;j++)
System.out.print("*");
System.out.println();
}
int p=n/2;
for(i=p;i>0;i--){
for(j=0;j<i;j++)
System.out.print("*");
System.out.println();
}
/*
Print the following pattern for the given number of rows.
Pattern for N = 7
*
**
***
****
***
**
*
Input format : N (Total no. of rows)
Output format : Pattern in N lines
Sample Input :
5
Sample Output :
*
**
***
**
*
*/
}
}
class GalaxyOfStars{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Solution s=new Solution();
int row=sc.nextInt();
s.print(row);
}
}