Cod sursa(job #2905650)

Utilizator alexdvResiga Alexandru alexdv Data 22 mai 2022 21:36:30
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;

char A[2000001], B[2000001];
int v[1000], pos = 0, times = 0;

int main() {
    ifstream fin("strmatch.in");
    ofstream fout("strmatch.out");
    cin >> A;
    cin >> B;
    char *p = strstr(B, A);
    while (p != 0) {
        ++times;
        ++pos;
        v[pos] = p  - B;
        p = strstr(p + 1, A);
    }
    cout << times << '\n';
    for (int i = 1; i <= pos; ++i) {
        cout << v[i] << ' ';
    }
    return 0;
}