結果

問題 No.3035 文字列のみの反転
ユーザー tenten
提出日時 2025-03-04 08:34:35
言語 Java
(openjdk 23)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,349 bytes
コンパイル時間 3,198 ms
コンパイル使用メモリ 80,828 KB
実行使用メモリ 51,724 KB
最終ジャッジ日時 2025-03-04 08:34:42
合計ジャッジ時間 5,548 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        String s = sc.next();
        int idx = 0;
        while (!isNumeric(s.charAt(idx))) {
            idx++;
        }
        System.out.println(new StringBuilder(s.substring(0, idx)).reverse() + s.substring(idx, s.length()));
    }
    
    static boolean isNumeric(char c) {
        return c >= '0' && c <= '9';
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");

    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}


0