結果

問題 No.163 cAPSlOCK
ユーザー megane_ankomegane_anko
提出日時 2021-02-09 03:06:14
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 81 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 112 ms
コンパイル使用メモリ 5,328 KB
実行使用メモリ 44,392 KB
最終ジャッジ日時 2023-09-20 11:55:11
合計ジャッジ時間 3,543 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,148 KB
testcase_01 AC 78 ms
42,144 KB
testcase_02 AC 78 ms
42,308 KB
testcase_03 AC 79 ms
42,472 KB
testcase_04 AC 79 ms
42,152 KB
testcase_05 AC 80 ms
42,332 KB
testcase_06 AC 79 ms
42,200 KB
testcase_07 AC 81 ms
42,468 KB
testcase_08 AC 80 ms
42,156 KB
testcase_09 AC 80 ms
42,316 KB
testcase_10 AC 81 ms
42,388 KB
testcase_11 AC 81 ms
42,296 KB
testcase_12 AC 79 ms
42,168 KB
testcase_13 AC 80 ms
42,380 KB
testcase_14 AC 81 ms
42,388 KB
testcase_15 AC 80 ms
44,392 KB
testcase_16 AC 80 ms
42,220 KB
testcase_17 AC 80 ms
42,384 KB
testcase_18 AC 81 ms
42,164 KB
testcase_19 AC 79 ms
42,156 KB
testcase_20 AC 79 ms
42,212 KB
testcase_21 AC 79 ms
42,308 KB
testcase_22 AC 78 ms
42,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const input = require('fs').readFileSync('/dev/stdin', 'utf8');

//文字列を1文字ずつ分割して配列にする、改行の部分を削除
//const ary = input.match(/.{1}/g)
const arr = input.split('\n')[0];
//答えを入れる配列を生成
let arr2 = [];
//console.log(arr);

for (let i = 0; i < arr.length; i++) {
    if (arr[i].match(/^[A-Z]*$/)) {
        //小文字に変換した文字を返す、処理してるだけ。
        //ary[i]に代入して、新しく作った配列に追加
        arr2.push(arr[i].toLowerCase());
        //console.log('if 文に入りました');
    } else {
        //大文字に変換
        arr2.push(arr[i].toUpperCase());
    }
}

console.log(arr2.join(""));
0