string 클래스의 멤버함수
헤더 : #include <string>
반환값 :
1. 찾는 문자의 첫번째 인덱스 값
2. 찾는 문자가 없는경우 string::npos를 리턴 (no position이라는 뜻으로 쓰레기 값)
#include <string>
#include <vector>
using namespace std;
int solution(string str1, string str2) {
int answer = 0;
if(str1.find(str2)!=string::npos)
{
return 1;
}
else
{
return 2;
}
return answer;
}
'C++' 카테고리의 다른 글
OpenGL : Laplacian Smoothing & Taubin Smoothing (0) | 2024.11.24 |
---|---|
cout 소수점 고정 (0) | 2024.11.24 |
STL : sort algorithm (0) | 2024.11.24 |
c++ string을 통 특정 문자 제거 (0) | 2024.11.24 |
string stream (0) | 2024.11.24 |