Cod sursa(job #1541466)
| Utilizator | Data | 4 decembrie 2015 03:31:33 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 26 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.68 kb |
#include <iostream>
#include <string.h>
#include <vector>
#include <fstream>
using namespace std;
int main()
{
ifstream f("strmatch.in");
ofstream g("strmatch.out");
string a,b;
int cnt=0,i,j,ok;
vector<int> ap;
f >> a;
f >> b;
for (i=0;i<=b.length()-a.length();i++)
{
ok = 0;
//cout << b[i];
for (j=0;j<a.length();j++)
if (b[i+j]!=a[j])
{
ok=1;
break;
}
if (ok==0)
{
cnt++;
ap.push_back(i);
}
}
g << cnt << endl;
for (i=0;i<ap.size();i++) g << ap[i] << " ";
f.close();
g.close();
return 0;
}
