-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZoho33.java
More file actions
74 lines (66 loc) · 893 Bytes
/
Copy pathZoho33.java
File metadata and controls
74 lines (66 loc) · 893 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.*;
import java.io.*;
class Zoho33
{
static void matrix(String str)
{
int len = str.length();
String rev= " ";
String[][] arr = new String[len][len];
int i,j;
for(i=0;i<len;i++)
{
for(j=0;j<len;j++)
{
arr[i][j]= " ";
}
}
i=0;
for(i=0;i<len;i++)
{
for(j=0;j<len;j++)
{
if(i==j)
{
char c=str.charAt(i);
String s = Character.toString(c);
arr[i][j]=s;
}
}
}
i=0;
j=0;
int k=0;
int m=len-1;
for(i=len-1;i>=0;i--)
{
for(j=0;j<len;j++)
{
if(j==k && i==m)
{
char d=str.charAt(j);
String si = Character.toString(d);
arr[i][j]=si;
k++;
m--;
}
}
}
//loop for printing the matrix:
for(i=0;i<len;i++)
{
for(j=0;j<len;j++)
{
System.out.print(arr[i][j]);
}
System.out.println();
}
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the word : ");
String str =sc.next();
matrix(str);
}
}