Pagini recente » Cod sursa (job #2489343) | Cod sursa (job #1473515) | Cod sursa (job #2462642) | Cod sursa (job #2426876) | Cod sursa (job #1327166)
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ifstream in("strmatch.in");
ofstream out("strmatch.out");
string a,b;
int n,m, total;
int *v;
void citire()
{
getline(in,a);
getline(in,b);
}
bool search(int i)
{
for(int j=1;j<=n;j++)
if(a[j-1] != b[j+i-1])
return 0;
return 1;
}
void match()
{
for(int i=1;i<=m;i++)
{
if(search(i))
{
v[++total] = i;
}
}
}
int main()
{
citire();
n = a.length();
m = b.length();
v = new int[n];
match();
out << total<<"\n";
for(int i=1;i<=total;i++)
out << v[i] << " ";
in.close();
out.close();
}