結果

問題 No.163 cAPSlOCK
ユーザー mtwtkman
提出日時 2019-10-13 23:02:33
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 629 bytes
コンパイル時間 12,175 ms
コンパイル使用メモリ 404,684 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-17 18:57:29
合計ジャッジ時間 12,580 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self, Read};

fn read_stdin() -> Vec<String> {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).ok();
    buffer.trim().split('\n').map(|s| s.to_string()).collect()
}

fn main() {
    let input = read_stdin();
    println!("{}",
        &input[0]
            .chars()
            .fold(String::new(), |acc, c| {
                let x = if c.is_lowercase() {
                    c.to_uppercase().next().unwrap()
                } else {
                    c.to_lowercase().next().unwrap()
                };
                format!("{}{}", acc, x.to_string())
            })
    );
}
0