Pagini recente » Cod sursa (job #2153536) | Cod sursa (job #1575449) | Cod sursa (job #2902562) | Cod sursa (job #1828393) | Cod sursa (job #1814285)
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ifstream f("strmatch.in");
ofstream g("strmatch.out");
int main(){
string a, b;
getline(f,a);
getline(f,b);
unsigned int i = 0, j = 0;
int v[1001];
int count = 0;
if (a.length() > b.length()) {
g << "0\n";
return (0);
}
while (b[i] != '\0' && a[j] != '\0') {
while (a[j] != '\0' && b[i] != '\0' && b[i] == a[j]) {
i++;
j++;
}
if (j == (a.length()) && count < 1000) {
v[count] = i - j;
++count;
}
i = i - j + 1;
j = 0;
}
g << count << "\n";
for (int i = 0; i < count; ++i)
g << v[i] << " ";
g << "\n";
f.close();
g.close();
return 0;
}