Cod sursa(job #2981980)
Utilizator | Data | 19 februarie 2023 12:57:52 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
string a,b,x;
int n,k,poz[1001];
int main()
{
f>>a;
f>>b;
n=a.size();
for(int i=0;i<b.size();i++)
{
if(b[i]==a[0])
{
x=b.substr(i,n);
if(x==a)
poz[++k]=i;
}
}
g<<k<<'\n';
for(int i=1;i<=k;i++)
g<<poz[i]<<" ";
return 0;
}