forked from rishav-mishra/Hacktober-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.java
More file actions
31 lines (31 loc) · 713 Bytes
/
program.java
File metadata and controls
31 lines (31 loc) · 713 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
import java.util.*;
class Pattern
{
public static void main ()
{
int i,sp,j,k,l;
Scanner in= new Scanner(System.in);
System.out.println("Enter the String ="); //accepting string
String s = in.nextLine();
l=s.length();
/*printing the pattern*/
for(i=0;i<l;i++)
if(i==l/2)
System.out.println(s);
else
{
sp=Math.abs((l/2)-i);
for(j=sp;j<l/2;j++)
System.out.print(" ");
k=0;
while(k<3)
{
System.out.print(s.charAt(i));
for(j=0;j<sp-1;j++)
System.out.print(" ");
k++;
}
System.out.println(" ");
}
}
}