Cod sursa(job #1428975)
Utilizator | Data | 5 mai 2015 13:47:53 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 24 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.61 kb |
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
std::ifstream fin("strmatch.in");
std::ofstream fout("strmatch.out");
int v[1010];
long long n=0;
std::string a,b;
int main()
{
fin>>a;
fin>>b;
int x,y;
x=b.find(a);
y=x;
if(x!=0){ n++;
v[n]=x;
while(x)
{
x=b.find(a,x+1);
if (x == std::string::npos) break;
y=x;
n++;
if(n<=1000)
{
v[n]=x;
}
}
}
fout<<n<<endl;
for(int a=1;a<=n;a++)
{
fout<<v[a]<<" ";
}
}