Cod sursa(job #1429069)
Utilizator | constantin teodor teoceltare | Data | 5 mai 2015 16:57:11 |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 24 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.64 kb |
#include<iostream>
#include<fstream>
#include<string>
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>>b;
int x;
x=b.find(a);
if(x!=0)
{
n++;
v[n]=x;
while(x)
{
x=b.find(a,x+1);
if (x == std::string::npos) break;
else{
n++;
if(n<=1000)
{
v[n]=x;
}
}
}
}
fout<<n<<'\n';
for(int a=1;a<=n;a++)
{
fout<<v[a]<<" ";
}
}