#include <stdio.h>
int main(void)
{
freopen("input.txt", "r", stdin);
setbuf(stdout, NULL);
int test_case;
int T = 10;
for (test_case = 1; test_case <= T; ++test_case)
{
int tc;
int match = 0;
int p_len = 0;
int t_len = 0;
char p[10]; // 주어짐
char t[1000]; // 주어짐
scanf("%d\n", &tc);
scanf("%s", p);
scanf("%s", t);
while (p[p_len] != '\0') {
// printf("%c",p[p_len]);
p_len = p_len + 1;
}
while (t[t_len] != '\0') {
// printf("%c",t[t_len]);
t_len = t_len + 1;
}
// printf("%c",t[t_len+1]);
int i = 0; int j = 0;
while (t[i] != '\0') {
if (t[i] != p[j]) {
i = i - j;
j = -1;
}
if (j == p_len - 1) {
// printf("%d %d\n", i,j);
match++;
j = -1;
}
++i;
++j;
}
// printf("%d %d %d", t_len, i, j);
printf("#%d %d\n", test_case, match);
}
return 0;//정상종료시 반드시 0을 리턴해야합니다.
}
댓글