Last active
July 28, 2019 04:02
-
-
Save surinoel/cbd36ba7bb6b58690bcb35bcd0caaac6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
char buf[10001]; | |
int main(void) { | |
scanf("%s", buf); | |
int cnt1 = 0; | |
char *ptr = strstr(buf, "JOI"); | |
while (ptr != NULL) { | |
cnt1 += 1; | |
ptr = strstr(ptr + 2, "JOI"); | |
} | |
printf("%d\n", cnt1); | |
int cnt2 = 0; | |
ptr = strstr(buf, "IOI"); | |
while (ptr != NULL) { | |
cnt2 += 1; | |
ptr = strstr(ptr + 1, "IOI"); | |
} | |
printf("%d\n", cnt2); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
string str; | |
int joi, ioi; | |
int main(){ | |
cin >> str; | |
size_t pos = 0; | |
while((pos = str.find("JOI", pos)) != string::npos) joi++, pos++; | |
pos = 0; | |
while((pos = str.find("IOI", pos)) != string::npos) ioi++, pos++; | |
cout << joi << '\n' << ioi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment