본문 바로가기
C++

[프로그래머스] 대문자와 소문자

by 띰쥬 2025. 9. 5.
728x90
반응형
SMALL

#include <string>
#include <vector>
#include <cctype>


using namespace std;

string solution(string my_string) {
    string answer = "";
    //대->소, 소->대
    //대:65~90, 소:97~102
    for(char str : my_string){
        if(isupper(str))
            answer += str+32;
        else
            answer += str-32;
    }
    return answer;
}

728x90
반응형
LIST

댓글