-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1543.cpp
42 lines (39 loc) · 837 Bytes
/
1543.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// 1543. 문서 검색
// 2021.07.04
// 브루트포스
#include<iostream>
#include<string>
using namespace std;
int main()
{
string original, toFind;
getline(cin, original);
getline(cin, toFind);
int ans = 0;
if (toFind.size() > original.size())
{
cout << ans << endl;
}
else
{
for (int i = 0; i < original.size() - toFind.size() + 1; i++)
{
bool flag = true;
for (int j = 0; j < toFind.size(); j++)
{
if (original[i + j] != toFind[j])
{
flag = false;
break;
}
}
if (flag)
{
ans++;
i += toFind.size() - 1;
}
}
cout << ans << endl;
}
return 0;
}