• PAT 1031


    简单题,字符串处理,注意index就可以了

     1 import java.util.*;
     2 import java.io.*;
     3 
     4 class FastReader{
     5     BufferedReader reader;
     6     StringTokenizer tokenizer;
     7     
     8     public FastReader(InputStream stream){
     9         reader = new BufferedReader(new InputStreamReader(stream), 1 << 10);
    10         tokenizer = null;
    11     }
    12     
    13     public String next(){
    14         while (tokenizer == null || !tokenizer.hasMoreTokens()){
    15             try{
    16                 tokenizer = new StringTokenizer(reader.readLine());
    17             } catch (Exception e){
    18                 throw new RuntimeException(e);
    19             }
    20         }
    21         
    22         return tokenizer.nextToken();
    23     }
    24     
    25     public long next_long(){
    26         return Long.parseLong(next());
    27     }
    28     
    29     public int next_int(){
    30         return Integer.parseInt(next());
    31     }
    32 }
    33 
    34 public class Main {
    35     public static void main(String[] args){
    36         FastReader reader = new FastReader(System.in);
    37         String process_str = reader.next();
    38         
    39         int size = process_str.length() + 2;
    40         int n1, n2, n3;
    41         
    42         n1 = n3 = size / 3;
    43         n2 = n1 + size % 3;
    44         size -= 2;
    45         
    46         StringBuilder white_space = new StringBuilder();
    47         for (int i = 0; i < n2 - 2; i++)
    48             white_space.append(' ');
    49         
    50         for (int i = 0; i < n1 - 1; i++)
    51             System.out.println(process_str.charAt(i) + white_space.toString() + process_str.charAt(size - i - 1));
    52         for (int i = n1 - 1; i <= size - n1; i++)
    53             System.out.print(process_str.charAt(i));
    54         System.out.println();
    55     }
    56 }
  • 相关阅读:
    rocketmq 修改broker和namesrv默认设置的堆内存大小
    linux 向文件中添加内容 sed
    页面 请求错误总结
    将pgsql中的所有表的序列当前值设置为所需的值
    pg 强制断开连接 删库
    测试的基本概念
    Linking(3)
    Linking(1)
    Linking(2)
    Nginx Learning (5)
  • 原文地址:https://www.cnblogs.com/EpisodeXI/p/4067947.html
Copyright © 2020-2023  润新知