View Code of Problem 3832

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char a[100000],b[100000];
    while(gets(a)!=NULL)
    {
    gets(b);
    int i,j,flag,count=0;
    flag=0;
    for(i=0;i<strlen(a);i++)
    {
        count=0;
        if(a[i]==b[0])
        {
            for(j=1;j<strlen(b);j++)
            {
                if(b[j]==a[i+j])
                {
                    count++;
                }
            }
        }
         if(count==(strlen(b)-1))
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
    {
         printf("%d\n",i+1);
    }
    else
         printf("%d\n",-1);

    }
    return 0;
}

Double click to view unformatted code.


Back to problem 3832