[프로그래머스/C++] 접두사인지 확인하기

꿈별·2023년 8월 22일
0

문제풀이

목록 보기
27/52

문제


풀이

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

using namespace std;

int solution(string my_string, string is_suffix) {
    string temp = "";

    for (int i = 0; i < my_string.length(); i++)
    {
        for (int j = 0; j < i+1; ++j)
        {
            temp += my_string[j];
        }
        if (temp == is_suffix)
            return 1;
        temp = "";
    }
    return 0;
}

0개의 댓글