fork download
  1. class A
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. A a = new A();
  6. a.a("Test");
  7. a.a("Hello World!");
  8. a.a("Hi");
  9. }
  10. static void a(String s){int h=s.length(),n=h*2-1,t=n-h,u=n-1;char[][]c=new char[n][n];for(int i=0;i<h;i++){c[0][t+i]=c[i][t-i]=c[t][t-i]=c[t+i][t]=c[t+i][u-i]=c[t-i][t+i]=c[t-i][u]=c[u][i]=c[u-i][0]=s.charAt(i);}for(int y=0;y<n;y++){System.out.println(new String(c[y]).replace('\0',' '));}}
  11. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
   Test
  e  ss
 s  e e
tseT  T
s  e e 
e  ss  
Test   
           Hello World!
          e          dd
         l          l l
        l          r  r
       o          o   o
                 W    W
     W                 
    o          o      o
   r          l       l
  l          l        l
 d          e         e
!dlroW olleH          H
d          e         e 
l          l        l  
r          l       l   
o          o      o    
W                      
           W    W      
o          o   o       
l          r  r        
l          l l         
e          dd          
Hello World!           
 Hi
iHH
Hi