삼각형 자 모 를 인쇄 하 다.

/**
        , F 
  :
  :F 
  :
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA

  :C 
  :
A
ABA
ABCBA

*/
import java.util.Scanner;
class Work17Letter 
{
	public static void main(String[] args) 
	{
		System.out.println("");
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		char ch=str.charAt(0);
		int a=(int)ch;
		if (a<65||a>90)
		{
			System.out.println("    ");
			return;
		}
		for (int i=65;i<=a ;i++ )
		{
			for (int n=65;n<=i ;n++ )
			{
				    System.out.print((char)n);
			}
			for (int m=i-1;m>=65 ;m-- )
			{
				    System.out.print((char)m);

			}
			    System.out.println("");
		}

	}
}
/**
        ,  F,   
  :
  :F 
  :
F
EFE
DEFED
CDEFEDC
BCDEFEDCB
ABCDEFEDCBA
  :D 
  :
D
CDC
BCDCB
ABCDCBA

*/
import java.util.Scanner;
class  Work18Letter
{
	public static void main(String[] args) 
	{
		System.out.println("         :");
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
		char ch=str.charAt(0);
		int x=(int)ch;
		if (x<65||x>90)
		{
			System.out.println("    ");
			return;
		}
		for (int i=x ;i>=65 ;i-- )//    
		{
			
			for (int n=x-i;n>=0 ;n-- )//   X    ,
			{
				    System.out.print((char)(x-n));
			}
			for (int m=1;m<=x-i ;m++ )
			{
				    System.out.print((char)(x-m));

			}
			    System.out.println("");
		}
		
	}
}

좋은 웹페이지 즐겨찾기