1213. [S/W 문제해결 기본] 3일차 - String 10 Oct 2019 in Algorithm on SWEA 문제링크[풀이]#include <iostream> #define MAXN 1001 using namespace std; int T, Q, sol; char Str[MAXN]; char Tar[11]; int _strlen(char * str) { int len = 0; while (*str++ != '\0') len++; return len; } void solve() { int index = 0; int tlen = _strlen(Tar); int Slen = _strlen(Str); while (index < Slen - tlen + 1) { for (int i = 0; i < tlen; ++i) { if (Tar[i] != Str[index + i]) { break; } if (i == tlen - 1) { sol++; } } index++; } } int main() { T = 10; for (int i = 1; i <= 10; ++i) { sol = 0; scanf("%d", &Q); scanf("%s", Tar); scanf("%s", Str); solve(); printf("#%d %d\n", Q, sol); } }