import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String word = sc.next();
StringBuffer strb = new StringBuffer(word);
int height = 1;
int whitespace = 0;
for (int i = 0; i < strb.length(); i++) {
strb.deleteCharAt(0);
strb.deleteCharAt(strb.length() - 1);
height++;
if (strb.length() < height) {
whitespace = strb.length();
height--;
break;
}
}
height--;
strb = new StringBuffer(word);
while (height > 0) {
System.out.print(strb.charAt(0));
for (int i = 0; i < whitespace; i++) {
System.out.print(" ");
}
System.out.print(strb.charAt(strb.length() - 1));
strb.deleteCharAt(0);
strb.deleteCharAt(strb.length() - 1);
System.out.println();
height--;
}
System.out.print(strb.toString());
}
}
PAT 甲级 1031 JAVA
最新推荐文章于 2021-03-03 15:03:38 发布