피너클의 it공부방
백준 2744 대소문자 바꾸기 (c++) : 피너클 본문
728x90
반응형
https://www.acmicpc.net/problem/2744
2744번: 대소문자 바꾸기
영어 소문자와 대문자로 이루어진 단어를 입력받은 뒤, 대문자는 소문자로, 소문자는 대문자로 바꾸어 출력하는 프로그램을 작성하시오.
www.acmicpc.net
간단한 구현문제다.
#include <iostream>
#include <string>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string str;
cin >> str;
for (int i = 0; i < str.length(); i++) {
if ('a' <= str[i] && str[i] <= 'z') str[i] = str[i] + ('A' - 'a');
else str[i] = str[i] - ('A' - 'a');
}
cout << str << endl;
}
전체코드다.
728x90
반응형
'백준' 카테고리의 다른 글
백준 15680 연세대학교 (C++) : 피너클 (0) | 2022.06.16 |
---|---|
백준 14581 팬들에게 둘러싸인 홍준 (c++) : 피너클 (0) | 2022.06.15 |
백준 14489 치킨 두 마리(...) (c++) : 피너클 (0) | 2022.06.13 |
백준 14470 전자레인지 (c++) : 피너클 (0) | 2022.06.12 |
백준 11365 !밀비 급일 (c++) : 피너클 (0) | 2022.06.11 |
Comments