字符串处理,直接硬搞的,早上有道字符串的题调了一早上都没调出来,真不爽,感觉好累,只好放弃了,唉
#include<stdio.h>
#include<string.h>
static void rotation(char *src, char *dst, int length, int index)
{
strncpy(dst + index, src, length - index);
strncpy(dst, src + length - index, index);
}
int main()
{
char a[1001], b[101];
while (gets(a) != NULL)
{
gets(b);
int i, j, total = 0, la = strlen(a), lb = strlen(b);
char temp[101];
for (i = 0; i <= la - lb; i++)
for (j = 0; j < lb; j++)
{
rotation(b, temp, lb, j);
if (!strncmp(a + i, temp, lb))
{
total++;
break;
}
}
printf("%d\n", total);
}
return 0;
}