PTA 古风排版 Java
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
Reader.init(System.in);
Writer.init(System.out);
slove();
Writer.close();
}
static void slove() throws IOException {
int row = Reader.nextInt();
char[] chs = Reader.nextLine().toCharArray();
int column = (chs.length - 1) / row + 1;
for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
int index = (column - j - 1) * row + i;
if(index >= chs.length) {
Writer.print(" ");
}else {
Writer.print(chs[index]);
}
}
Writer.print("\n");
}
}
}
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static String nextLine() throws IOException {
return reader.readLine();
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static long nextLong() throws IOException {
return Long.parseLong(next());
}
static char nextChar() throws IOException {
return next().toCharArray()[0];
}
static float nextFloat() throws IOException {
return Float.parseFloat(next());
}
static Double nextDouble() throws IOException {
return Double.parseDouble(next());
}
}
class Writer {
static BufferedWriter writer;
static void init(OutputStream outputStream) {
writer = new BufferedWriter(new OutputStreamWriter(outputStream));
}
static void print(Object object) throws IOException {
writer.write(object.toString());
}
static void println(Object object) throws IOException {
writer.write(object.toString());
writer.write("\n");
}
static void close() throws IOException {
writer.close();
}
}