Cod sursa(job #1517519)

Utilizator andy1207Cioltan Andrei andy1207 Data 4 noiembrie 2015 15:11:04
Problema Potrivirea sirurilor Scor 16
Compilator cpp Status done
Runda Arhiva educationala Marime 0.78 kb
#include<cstdio>
char v[2000001],v1[2000001],v2[2000001];
int main()
{
 int i,j,q,w,f,cq;
 char c;
 freopen("strmatch.in","r",stdin);
 freopen("strmatch.out","w",stdout);
 i=1;
 while(c!='\n')
      {
       scanf("%c",&c);
       if(c!='\n')
          {
           v[i]=c;
           i++;
          }
      }
 j=1;
 c='1';
 while(c!='\n')
      {
       scanf("%c",&c);
       if(c!='\n')
          {
           v1[j]=c;
           j++;
          }
      }
 f=1;
 for(q=1;q<=j-1;q++)
    {
     cq=q;
     for(w=1;w<=i-1 && v[w]==v1[cq];w++)
        {
         cq++;
        }
     if(w==i)
        {
         v2[f]=q-1;
         f++;
        }
    }
 printf("%d\n",f-1);
 for(i=1;i<=f-1;i++)
    {
     printf("%d ",v2[i]);
    }
return 0;
}