PAT--00-自测1. 打印沙漏(20)

import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		String symbol = in.next();
		int k = findN(num);
		int left =0;
		if(k!=0){
			left = (char) (num-2*Math.pow(k, 2)+1);
		}
		
		
		int n = 2*k-1;
		for(int i =1 ;i<= n;i++){
			printspace(n/2-(int) Math.abs(i-n/2-1) );
			printstart((int)(2*Math.abs(i-n/2-1)+1),symbol);
//			printspace(n/2-(int) Math.abs(i-n/2-1) );
			System.out.println();
		}
		
		System.out.print(left);
		
		
		
	}

	private static void printstart(int i, String symbol) {
		// TODO Auto-generated method stub
		for(int k = 0;k

你可能感兴趣的:(PAT--00-自测1. 打印沙漏(20))