グラフィック出力の実装

2322 ワード

import java.util.*;
import java.io.*;
public class Letter{
	public static int count(char x){
		if(x>='A' && x<='Z')	return x-'A'+1;
		else return x-'a'+1;
	}
	public static void  printOut(char aa){
		    int x;int j;
			char tt,yy;
			char temp;
			if(aa>='A' && aa<='Z')	{
				temp='A';
				x=aa-'A'+1;}
				else if(aa>='a' && aa<='z'){
					temp='a';
					x=aa-'a'+1;}
				else {temp='a';x=0;
				}
			for(int i=1;i<=x;i++){
				for(int k=x;k>i;k--) System.out.print(" ");			
				for(j=1;j<=i;j++) 	{
					tt=(char)(temp+j-1);
					System.out.print(tt);					
				}
				tt=(char)(temp+i-1);
				for(int m=1;m<=j-2;m++) {
					yy=(char)(tt-m);
					System.out.print(yy);				
				}
				System.out.println();
			}
		
	}
	public static void main(String[] args) throws Exception{
		System.out.println(" , :");
		Scanner reader=new Scanner(System.in);
		String xx=reader.next();
		char aa=xx.charAt(0);		
		printOut(aa);
	}
}

 :


 , :
W
                      A
                     ABA
                    ABCBA
                   ABCDCBA
                  ABCDEDCBA
                 ABCDEFEDCBA
                ABCDEFGFEDCBA
               ABCDEFGHGFEDCBA
              ABCDEFGHIHGFEDCBA
             ABCDEFGHIJIHGFEDCBA
            ABCDEFGHIJKJIHGFEDCBA
           ABCDEFGHIJKLKJIHGFEDCBA
          ABCDEFGHIJKLMLKJIHGFEDCBA
         ABCDEFGHIJKLMNMLKJIHGFEDCBA
        ABCDEFGHIJKLMNONMLKJIHGFEDCBA
       ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
      ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
     ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
    ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
   ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
  ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
 ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA

F:\help>