Cod sursa(job #1153803)
Utilizator | Data | 25 martie 2014 19:03:56 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
#include<string>
using namespace std;
ifstream in("strmatch.in");
ofstream out("strmatch.out");
int main()
{
string m,n,p;
in>>m>>n;
int i=1;
while(m.at(0)!=m.at(i)) i++;
p=m.substr(0,i);
i=0;
while(i<n.length())
{
if(n.substr(i,p.length())==p)
{
if(n.substr(i,m.length())==m) out<<i<<" ";
i+=2;
}
else i++;
}
}