Pagini recente » Cod sursa (job #2097799) | Cod sursa (job #1340308) | Cod sursa (job #2067374) | Cod sursa (job #2746126) | Cod sursa (job #2611200)
#include <iostream>
#include<fstream>
#include<string>
#include <vector>
using namespace std;
int main() {
string minta, str;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
getline(fin, minta);
getline(fin, str);
int minta_hossz = minta.size();
int str_hossz = str.size();
int db = 0;
vector<int> a;
for (int i = 0; i < str_hossz; i++) {
int j;
for (j = 0; j < minta_hossz; j++) {
if (str[i + j] != minta[j]) break;
if (j == minta_hossz - 1) {
a.push_back(i);
db++;
}
}
}
fout << db << "\n";
if (db > 1000) {
for (int i = 0; i <= 999; i++) {
fout << a[i] << " ";
}
}
else {
for (auto& e : a) {
fout << e << " ";
}
}
}