https://www.acmicpc.net/problem/2744
2744번: 대소문자 바꾸기
영어 소문자와 대문자로 이루어진 단어를 입력받은 뒤, 대문자는 소문자로, 소문자는 대문자로 바꾸어 출력하는 프로그램을 작성하시오.
www.acmicpc.net
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().trim().split("");
input.forEach((i, index) => {
if(i.charCodeAt() >= 65 && i.charCodeAt() <= 90) {
input[index] = String.fromCharCode(i.charCodeAt()+32);
} else {
input[index] = String.fromCharCode(i.charCodeAt()-32);
}
})
console.log(input.join(""));
728x90
'Algorithm&CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [9093] 단어 뒤집기 (0) | 2023.02.10 |
---|---|
[Baekjoon] [10808] 알파벳 개수 (0) | 2023.02.10 |
[Baekjoon] [2750] 수 정렬하기 (0) | 2023.02.09 |
[Baekjoon] [1316] 그룹 단어 체커 (0) | 2023.02.09 |
[Baekjoon] [10773] 제로 (0) | 2023.02.09 |