Pagini recente » Cod sursa (job #996607) | Cod sursa (job #2205153) | Cod sursa (job #703000) | Cod sursa (job #2197428) | Cod sursa (job #1360802)
#include <fstream>
#include <string.h>
#define mini(a, b) ((a < b) ? a : b)
using namespace std;
char STR[2000000];
char CMP[2000000];
int megold[2000000];
int eltol;
int M,N;
int q;
ifstream in("strmatch.in");
ofstream out("strmatch.out");
void beolvas(){
in >> CMP >> STR;
M = strlen(CMP);
N = strlen(STR);
}
int main(){
beolvas();
for(int i = 0;i<N;i++){
for(int j = 0;j<M;j++){
if(STR[j] != CMP[j]){
break;
}else if(j == strlen(CMP)-1){
megold[q] = (i+eltol)/2;
q++;
}
}
for(int j = 0;j<strlen(STR);j++){
STR[j] = STR[j+1];
}
eltol++;
}
out << q << endl;
for(int i = 0;i<mini(q,1000);i++){
out << megold[i] << " ";
}
}