forked from Amigo2k20/java_programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathX Star Pattern.java
More file actions
41 lines (22 loc) · 849 Bytes
/
X Star Pattern.java
File metadata and controls
41 lines (22 loc) · 849 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
import java.util.Scanner;
public class Xstar
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter N : ");
int n=sc.nextInt();
System.out.print("Enter Symbol : ");
char c = sc.next().charAt(0);
int k=n*2-1;
for(int i=1;i<=k;i++)
{
for(int j=1;j<=k;j++)
{ if(j==i || j==k-i+1)
System.out.print(c);
System.out.print(" ");
}
System.out.println();
}
}
}