Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int k=0,n,index,i=0;
- char s[18][18];
- char p[100];
- char t[100];
- gets(p);
- gets(t);
- n=strlen(t);
- strcpy(s[k],"");
- while(strcmp(s[k],p)!=0&&k<n)
- {
- if(t[k]==p[i++])
- //if(strcmp(t[k],p[i++])==0)
- {
- strcat(s[k],t[k]);
- strcpy(s[k+1],s[k]);
- }
- else
- {
- strcpy(s[k+1],"");
- i=0;
- }
- k++;
- }
- if(strcmp(s[k],p)==0)
- {
- index=k-strlen(p)+1;
- }
- else
- index=0;
- printf("%d",index);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment