-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5586.cpp
More file actions
47 lines (44 loc) · 744 Bytes
/
5586.cpp
File metadata and controls
47 lines (44 loc) · 744 Bytes
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
43
44
45
46
47
// 5586. JOI와 IOI
// 2019.05.21
// 문자열 처리
#include<iostream>
#include<string>
using namespace std;
char joi[3] = { 'J','O','I' };
char ioi[3] = { 'I','O','I' };
int main()
{
string s;
cin >> s;
int joiCount = 0;
int ioiCount = 0;
for (int i = 0; i < s.size() - 2; i++)
{
bool joiFlag = true;
bool ioiFlag = true;
int cnt = i;
// 문자열 3개를 joi,ioi와 각각 비교하여 틀리면 flag를 false로 바꾼다.
for (int j = 0; j < 3; j++)
{
if (s[cnt] != joi[j])
{
joiFlag = false;
}
if (s[cnt] != ioi[j])
{
ioiFlag = false;
}
cnt++;
}
if (joiFlag)
{
joiCount++;
}
if (ioiFlag)
{
ioiCount++;
}
}
cout << joiCount << endl << ioiCount << endl;
return 0;
}