Pagini recente » Profil M@2Te4i | Rating Plesa Vlad (lowrunner) | Cod sursa (job #2220331) | Cod sursa (job #1763374) | Cod sursa (job #796856)
Cod sursa(job #796856)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main() {
string A, B;
ifstream in("strmatch.in");
in >> A >> B;
in.close();
vector<int> poz;
int nr_matches = 0;
int N = B.length();
int M = A.length();
for(int i = 0; i <= N-M; i++) {
if(B.compare(i,M, A) == 0) {
nr_matches++;
if(nr_matches <= 1000)
poz.push_back(i);
}
}
ofstream out("strmatch.out");
out << nr_matches << endl;
for(int i = 0; i < poz.size(); i++)
out << poz[i] << " ";
out.close();
return 0;
}