Cod sursa(job #3037562)
Utilizator | Data | 25 martie 2023 19:53:31 | |
---|---|---|---|
Problema | Potrivirea sirurilor | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
#define MAX 2000000
char a[MAX], b[MAX];
int t = 0;
vector<int> ap;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int main() {
f >> a >> b;
auto s = strstr(b, a);
while (s) {
ap.push_back(s - b);
t++;
s = strstr(s + 1, a);
}
g << t << endl;
for (auto x : ap) g << x << " ";
return 0;
}