-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStarpatternSpace.java
More file actions
43 lines (38 loc) · 993 Bytes
/
StarpatternSpace.java
File metadata and controls
43 lines (38 loc) · 993 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
import java.util.Scanner;
public class StarpatternSpace
{
public static void row(int i, int n)
{
if(i <=n)
{
space(1, i, n);
col(1, i);
System.out.println();
row(i+1, n);
}
}
public static void space(int j, int i, int n)
{
if(j <=n-1)
{
System.out.print(" ");
space(j+1, i, n);
}
}
public static void col(int j, int i)
{
if(j <=i)
{
System.out.print("*");
col(j+1, i);
}
}
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Enter Size");
int n = in.nextInt();
row(1,n);
in.close();
}
}