Cod sursa(job #2909807)

Utilizator vladiiiVlad Martiniuc vladiii Data 15 iunie 2022 22:29:05
Problema Potrivirea sirurilor Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
string a, b;
int pos[1000], pin;

bool found(int bi) {
	for (int ai = 1; ai < a.size(); ai++) {
		if (a[ai] != b[++bi]) return false;
	}
	return true;
}
int main() {
	
	f >> a >> b;
	for (size_t i = 0; i < b.size(); i++)
	{
		if (b[i] == a[0] && found(i)) { if (pin < 1000) pos[pin] = i; pin++; }
	}
	g << pin - 1 << endl;
	for (size_t i = 0; i < pin && i < 1000; i++) g << pos[i] << " ";


}