Skip to content

Instantly share code, notes, and snippets.

@overnew
Created October 26, 2020 11:16
Show Gist options
  • Save overnew/b587529e08010ecd991146725c82bb74 to your computer and use it in GitHub Desktop.
Save overnew/b587529e08010ecd991146725c82bb74 to your computer and use it in GitHub Desktop.
문서 검색 정답 코드
#include <iostream>
#include<string>
using namespace std;
int main() {
string document;
string word;
int count=0;
getline(cin,document);
getline(cin,word);
if(document.length() <word.length())
cout<<0<<'\n';
else{
for(int i=0; i<=document.length()-word.length() ; ++i)
if(document.substr(i,word.length()) == word ){
++count;
i+= (word.length()-1);
}
cout<<count<<'\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment