#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define Max 20
int main() {
int i,j,t,m,n,p=0;
char str1[20] ; //存储第一个字符串
char str2[20] ; //存储第二个字符串
char stem[20] = {"\0"}; //辅助数组
printf("第一个字符串\n");
gets(str1);
printf("第二个字符串\n");
gets(str2);
m = strlen(str1);
n = strlen(str2);
if (m < n){ //保证第一个数组是长的字符串
t = m;
m = n;
n = t;
strcpy(stem, str1);
strcpy(str1,str2);
strcpy( str2,str1);
}
for (i = 0; (i < m - n + 1)&&(p==0); i++){
for ( j = 0; j < n; j++)
{
if (str1[j+i] != str2[j])
break;
}
if ((j == n)&&(str1[j+i-1] == str2[j-1]))
{
p = 1;
}
}
p == 1 ? printf("子串,从第%d开始\n", i) : printf("不是子串\n");
}