Cod sursa(job #2335409)
| Utilizator | Data | 4 februarie 2019 00:38:41 | |
|---|---|---|---|
| Problema | Potrivirea sirurilor | Scor | 14 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
int main()
{
char *p;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char c[2000000];
f>>c;
int m;
m=strlen(c);
char b[m+5];
strcpy(b,c);
f>>c;
int n;
n=strlen(c);
char a[n+3];
strcpy(a,c);
int pot[1001];
int i;
i=0;
pot[-1]=-1;
while(strstr(a,b)!=NULL){
p=strstr(a,b);
pot[i]=p-a+pot[i-1]+1;
i++;
if(i==1000)break;
strcpy(a,p+1);
}
g<<i<<endl;
for(int j=0;j<i;j++)g<< pot[j]<<" ";
}
