본문 바로가기

코딩테스트

프로그래머스_0단계_문자열 정렬하기 (1)C++

 

문제풀이: 

 

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> solution(string my_string) {
    vector<int> answer;
    
    for(char c: my_string)
    {
        if(c>='0' && c<='9')
        {
            answer.push_back(c-'0');
        }
    }
    sort(answer.begin(),answer.end());
    return answer;
}