Pagini recente » Cod sursa (job #1621672) | Cod sursa (job #58836) | Cod sursa (job #956908) | Cod sursa (job #1643512) | Cod sursa (job #912574)
Cod sursa(job #912574)
#include <fstream>
#include <string.h>
#define max 2000000
#define maxx 1000
using namespace std;
char a[max],b[max];
int poz[max],k=0;
int main()
{
ifstream f("strmatch.in");
ofstream g("strmatch.out");
f>>a>>b;
for(int i=0;i<strlen(b)-strlen(a);i++)
{
if(*a==b[i])
{
bool ok=true;
for(int j=0;j<strlen(a);j++)
{
if(a[j]!=b[j+i])
ok=false;
}
if(ok)
{
poz[k]=i;
k++;
}
}
}
g<<k<<'\n';
for(int i=0;i<k&&i<maxx;i++)
{
g<<poz[i]<<' ';
}
return 0;
}