#include<stdio.h>
#include<string.h>
char a[11], b[1000001], c[13], d[1000003];
void capital(char* p)
{
int i, n = strlen(p);
for (i = 0; i < n; i++)
{
if (*(p + i) >= 'a' && *(p + i) <= 'z')
{
(*(p + i)) -= 32;
}
}
}
int main(void)
{
int i, x, y, j, s, t;
gets(a);
gets(b);
x = strlen(a);
y = strlen(b);
a[x] = ' ';
a[x + 1] = '\0';
c[0] = ' ';
strcat(c, a);
b[y] = ' ';
b[y + 1] = '\0';
d[0] = ' ';
strcat(d, b);
capital(c);
capital(d);
if (strstr(d, c) == NULL)
{
printf("-1");
return(0);
}
else
{
s=strstr(d,c)-d;
for (i = 0,j=0; strstr(d, c) != NULL; i++)
{
t = strstr(d, c) - d + x + 1;
for (; j < t; j++)
d[j] = '0';
}
printf("%d %d", i, s);
return(0);
}
}
洛谷P1308 [NOIP2011 普及组] 统计单词数经典解法
最新推荐文章于 2024-07-05 08:08:54 发布