Pagini recente » Cod sursa (job #1342096) | Cod sursa (job #2677111) | Cod sursa (job #1912158) | Cod sursa (job #1127893) | Cod sursa (job #2677251)
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;
#define min(a, b) (a < b?a: b)
ifstream fin("strmatch.in");
ofstream fout("strmatch.out");
char string_array[2000005], pattern[2000005];
int main(){
char *value;
int vec[1001];
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;
if(cnt < 1000){
vec[cnt] = new_value;
}
cnt++;
new_value += 1;
OK = 1;
}
if(OK == 0){
break;
}
}
fout << cnt << "\n";
for(int i = 0; i < min(cnt, 1000); i++){
fout << vec[i] << " ";
}
return 0;
}