题解 | #字符逆序# java 直接读取reverse 103ms

字符逆序

http://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b

import java.util.*;
import java.io.*;

public class Main {

    static PrintWriter pw;

    private void run() {
        // read_write_file(); // comment this before submission
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine(), res = "";
        int n = s.length();
        for (int i = n - 1; i >= 0; i--) res += s.charAt(i);
        pr(res);
    }

    private final String INPUT = "input.txt";
    private final String OUTPUT = "output.txt";

    void read_write_file() {
        FileInputStream instream = null;
        PrintStream outstream = null;
        try {
            instream = new FileInputStream(INPUT);
            outstream = new PrintStream(new FileOutputStream(OUTPUT));
            System.setIn(instream);
            System.setOut(outstream);
        } catch (Exception e) {
        }
    }

    public static void main(String[] args) {
        pw = new PrintWriter(System.out);
        new Main().run();
        pw.close();
    }

    void pr(int num) {
        pw.println(num);
    }

    void pr(long num) {
        pw.println(num);
    }

    void pr(double num) {
        pw.println(num);
    }

    void pr(String s) {
        pw.println(s);
    }

    void pr(char c) {
        pw.println(c);
    }

    void tr(Object... o) {
        pw.println(Arrays.deepToString(o));
    }
}
全部评论

相关推荐

10-30 23:23
已编辑
中山大学 Web前端
去B座二楼砸水泥地:这无论是个人素质还是专业素质都👇拉满了吧
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务