Pagini recente » Borderou de evaluare (job #923603) | Cod sursa (job #923317)
Cod sursa(job #923317)
#include <fstream>
using namespace std;
static const int MAXN = 2000001, MAXA = 1000;
char T[MAXN], P[MAXN];
int A[MAXA];
int main() {
int ans = 0;
ifstream f("strmatch.in");
f >> P >> T;
f.close();
for(int i = 0; T[i]; i++) {
bool match = true;
for(int j = 0; P[j]; j++) {
if(P[j] != T[i + j]) {
match = false;
break;
}
}
if(match) {
if(ans < MAXA) A[ans] = i;
ans++;
}
}
ofstream g("strmatch.out");
g << ans << endl;
for(int i = 0; i < MAXA && i < ans; i++) {
g << A[i] << ' ';
}
g << endl;
g.close();
return 0;
}