문제출처 : https://www.acmicpc.net/problem/1543
code
#include <stdio.h> #include <string.h> int main() { char arr[2500] = { NULL }, search[50] = { NULL }; gets(arr); gets(search); int arr_len = strlen(arr), search_len = strlen(search), cnt = 0; for (int i = 0; i < arr_len; i++) { int flag = 1; for (int j = 0; j < search_len; j++) { if (arr[i+j] != search[j]) { flag = 0; break; } } if (flag == 1) { cnt++; i += search_len-1; } } printf("%d", cnt); return 0; }