#include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #define N 100 using namespace std; int main() { char str1[100000],str2[100000]; while(scanf("%s\n%s",&str1,&str2)!=EOF) { char *p=strstr(str1,str2); if(p) printf("%d\n",p-str1+1); else printf("-1\n");; /*char ans[1000]; int len1=0,len2=0,k=0,leap=0; len1=strlen(str1); len2=strlen(str2); for(int i=0;i<len1;i++) { if(leap==1) { printf("%d\n",i); break; } if(str1[i]==str2[0]) { for(int j=i;j<i+len2;j++) ans[k++]=str1[j]; } if(strcmp(str2,ans)==0) leap=1; } if(leap==0) printf("-1\n");*/ } } |
Double click to view unformatted code.