https://www.acmicpc.net/problem/2744
아이디어:
1. string 자료형 사용 > for문, 배열처럼 접근 가능
2. ascii코드 값 활용 > 대문자 + 32 = 소문자, 소문자 - 32 = 대문자
// 2744
#include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
string str;
cin >> str;
for (int i = 0; i < str.size(); i++) {
if ('A' <= str[i] && str[i] <= 'Z') {
str[i] += 32;
}
else if ('a' <= str[i] && str[i] <= 'z') {
str[i] -= 32;
}
}
cout << str;
return 0;
}'algorithm' 카테고리의 다른 글
| 백준 15964번 이상한 기호 (0) | 2024.10.27 |
|---|---|
| 백준 2754번 학점계산 (1) | 2024.10.27 |
| 백준 10872번 팩토리얼 (1) | 2024.10.27 |
| 백준 2741번 N 찍기 (2) | 2024.10.27 |
| 백준 2420번 사파리월드 (0) | 2024.10.27 |