SFPC/2022 SFPC Pre

경상북도 시군 이름

jemin0619 2024. 1. 10. 20:31

 

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

using namespace std;

int main() {
    string x, target;
    cin >> x >> target;
    if(x.find(target)==string::npos) cout << "X";
    else cout << "O";
    return 0;
}

 

string에 속한 find 함수를 사용하면 쉽게 풀 수 있다.

 

str1.find(str2) 를 하게 된다면 str1에 str2가 속해있는지 확인 후 해당 문자의 시작 인덱스를 반환한다.

만약 없다면 string::npos를 반환한다.