Pagini recente » Cod sursa (job #1841556) | Cod sursa (job #232128) | Cod sursa (job #2677238)
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char string_array[2000000], pattern[2000000];
int main(){
char *value;
int vec[10000];
int n, cnt = 0, OK;
fin >> pattern;
fin >> string_array;
n = strlen(string_array);
int new_value = 0;
while(new_value < n){
value = strstr(string_array + new_value, pattern);
OK = 0;
if(value){
new_value = value - string_array;
vec[cnt] = new_value;
cnt++;
new_value += 1;
OK = 1;
}
if(OK == 0){
break;
}
}
fout << cnt << "\n";
for(int i = 0; i < cnt; i++){
fout << vec[i] << " ";
}
return 0;
}