Pagini recente » Cod sursa (job #2846236) | Cod sursa (job #1122428) | Cod sursa (job #1122875) | Cod sursa (job #1948192) | Cod sursa (job #2391557)
#include <iostream>
#include <fstream>
#include <string.h>
#include <vector>
#define MAXIM 2000010
#define d 256
#define q 100007
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
char A[MAXIM], B[MAXIM];
int hashA, hashB, power = 1, nrSol;
vector <int> G;
void printOccurrences(string txt, string pat)
{
int found = txt.find(pat);
while (found != string::npos) {
nrSol++;
if(nrSol <= 999) G.push_back(found);
found = txt.find(pat, found + 1);
}
}
int main()
{
f >> A >> B;
printOccurrences(B, A);
g << nrSol << '\n';
for(unsigned int i = 0; i < G.size(); i++)
g << G[i] << ' ';
f.close();
g.close();
return 0;
}